Actually this question will be paid very less attention here  because its
ML forum . But anyways, you can try to
vectorize  your code using numpy or can use the same code snippet infused
with
numba (JIT Compiler). See this
http://nbviewer.ipython.org/github/aterrel/HPCPythonSC2012/blob/master/02_Speeding_Python.ipynb
Hope this helps!


On Tue, Aug 5, 2014 at 4:32 PM, Bao Thien <[email protected]> wrote:

> sorry, A is also array of (size1, size2)
>
>
> On Tue, Aug 5, 2014 at 4:28 PM, Bao Thien <[email protected]> wrote:
>
>> Hi all scikit-learn users,
>>
>> Suppose that we have the code like:
>>
>>
>> for i in np.arange(size1):
>>         for j in np.arange(size1):
>>             if j!=i:
>>                 t = 0.
>>                 for k in np.arange(size2):
>>                     for l in np.arange(size2):
>>                        t = t + np.sum(A[i,k]*A[j,l]*X2[C[i,k],C[j,l]])
>>
>>                 tmp = tmp + (X1[i,j] - t)*(X1[i,j] - t)
>> return tmp
>>
>>
>> where X1 is the array of (size1, size1) and  similar to X2 (size2, size2)
>> C is array of (size1, size2)
>>
>> I try to rewrite this code to reduce the computational time, but somehow
>> it does not success.
>>
>> If anyone can help me, it would be very appreciated
>>
>> Thank in advance.
>>
>> T.B
>>
>>
>
>
> --
> Nguyen Thien Bao
>
> NeuroInformatics Laboratory (NILab), Fondazione Bruno Kessler (FBK),
> Trento, Italy
> Centro Interdipartimentale Mente e Cervello (CIMeC), Universita degli
> Studi di Trento, Italy
> Surgical Planning Laboratory (SPL), Department of Radiology, BWH, Harvard
> Medical School, USA
> Email: bao at bwh.harvard.edu or tbnguyen at fbk.eu or ntbaovn at
> gmail.com
> Fax: +39.0461.283.091
> Cellphone:   +1. 857.265.6408 (USA)
>                  +39.345.293.1006 (Italy)
>                  +84.996.352.452 (VietNam)
>
>
> ------------------------------------------------------------------------------
> Infragistics Professional
> Build stunning WinForms apps today!
> Reboot your WinForms applications with our WinForms controls.
> Build a bridge from your legacy apps to the future.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>


-- 
    Warm Regards
    Yogesh Karpate
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to