Skip to content

Conversation

nouiz
Copy link
Contributor

@nouiz nouiz commented Aug 6, 2013

No description provided.

@moorepants
Copy link
Member

Cool, thanks!

moorepants added a commit that referenced this pull request Aug 6, 2013
Use 2 "tricks" to speed up Theano version.
@moorepants moorepants merged commit 5af7654 into pydy:master Aug 6, 2013
@moorepants
Copy link
Member

Why does changing this matter?:

#inp = np.random.random(len(arguments))
inp = [np.asarray(x) for x in np.random.random(len(arguments))]

I need to do it below for the np.hstack line in the right_hand_side function too.

@nouiz
Copy link
Contributor Author

nouiz commented Aug 6, 2013

np.random.random(len(arguments)) is a numpy.ndarray of 1 dimensions.
when you do a_function(*a_ndarray_vector)
this create a tuple of numpy scalar, that is passed as input to the function.

numpy scalar are different object then numpy.ndarray, even when numpy.ndarray have 0 dimensions. theano_function() create a theano function that expect numpy.ndarray as inputs, not numpy.scalar. There is good reason for that, but in short, Theano have a better support for numpy.ndarray then numpy scalar.

So to make a "fair" comparison, you need to move out the cast outside of the timming of Theano. This is particulary important as this add much overhead to Theano due to a weakness in Theano in that case.

@moorepants
Copy link
Member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants