2013/7/8 Issam <[email protected]>:
> On 7/8/2013 12:53 PM, Lars Buitinck wrote:
>> cost = np.sum(np.einsum('ij,ji->i', diff, diff.T)) / (2 * n_samples)
> Thanks for all the remarks!
>
> I found out that the `einsum` can be replaced simply  by 'cost =
> np.sum(diff**2)/ (2 * n_samples)' which is faster and more readable.

For vectors x, note that np.sum(x ** 2) == np.dot(x, x), and the
latter can be a lot faster.

-- 
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to