what's the meaning of debug info: Inputs strides

958 views
Skip to first unread message

Wenpeng Yin

unread,
Jan 10, 2015, 2:36:34 AM1/10/15
to theano...@googlegroups.com
hello, guys,

Usually, theano will print out some error info if something goes wrong, like:

ValueError: total size of new array must be unchanged
Apply node that caused the error: Reshape{2}(AdvancedSubtensor1.0, TensorConstant{[ 100 4000]})
Inputs shapes: [(0, 200), (2,)]
Inputs strides: [(1600, 8), (8,)]
Inputs types: [TensorType(float64, matrix), TensorType(int64, vector)]


But I can not understand the meaning of "Input strides", could any body give hints?   Thanks a lot! 

Michael Eickenberg

unread,
Jan 10, 2015, 9:18:03 AM1/10/15
to theano...@googlegroups.com
Strides encode the number of steps needed in memory to step along a given axis in an array. Numpy works the same way and allows direct access to this information:

In [1]: import numpy as np

In [2]: a = np.arange(30.).reshape(2, 3, 5)

In [3]: a.strides
Out[3]: (120, 40, 8)

In [4]: a.shape
Out[4]: (2, 3, 5)

A step in the last axis consists of 8 bytes (the size of a float64). A step in the second axis consists of 5 * 8 bytes = 40 bytes. A step in the first axis consists of 3 * 5 * 8 bytes = 120 bytes.

This arrangement presupposes C-ordering. In general, the strides contain additional information on how the data is represented in memory which you cannot deduce solely from the shape.

Hope this helps a little,
Michael


--

---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wenpeng Yin

unread,
Jan 12, 2015, 4:05:06 AM1/12/15
to theano...@googlegroups.com
thank you Michael, it helps much.

Best.


************************************************************************************
Wenpeng Yin

--

---
You received this message because you are subscribed to a topic in the Google Groups "theano-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/theano-users/pECnBxfd_kg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to theano-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages