Question

Recently have run into issues getting predictions for a trained pylearn2 model. The relevant bits of the traceback are provided below. I have ensured that model.get_input_shape() matches the shape of the numpy array I'm passing in to the theano prediction function I've generated, but still receive the following error.

ValueError: some matrix has no unit stride
Apply node that caused the error: Dot22(Elemwise{Composite{[Switch(GT(*1 -> add(i0, i1), i2), *1, i2)]}}[(0, 0)].0, y_W)
Inputs types: [TensorType(float32, matrix), TensorType(float32, matrix)]
Inputs shapes: [(1, 1000), (1000, 1)]
Inputs strides: [(9223372036854775807, 4), (4, 9223372036854775807)]
Inputs scalar values: ['not scalar', 'not scalar']

Interestingly enough, behavior seems to be machine-dependent. I have the prediction script working on my local machine, but execution on a Google Compute Engine instance produces the above error.

Any ideas where I might start debugging? The input strides look pretty odd, but I'm unsure how to begin debugging that value.

Was it helpful?

Solution

The problem is that NumPy create an ndarray with wrong strides. This was fixed in more recent version of NumPy. So update NumPy and it should work.

This is the line that show NumPy strides are bad:

Inputs strides: [(9223372036854775807, 4), (4, 9223372036854775807)]

Did you compile NumPy with some special flags to test strides for dimensions of size 1?

Here I did a PR to be more tolerant to those invalid strides:

https://github.com/Theano/Theano/pull/2008
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top