Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

why my own gray scale image can't work use train_mnisy.py as example #1912

Closed
ruobo opened this issue Apr 20, 2016 · 2 comments
Closed

why my own gray scale image can't work use train_mnisy.py as example #1912

ruobo opened this issue Apr 20, 2016 · 2 comments

Comments

@ruobo
Copy link

ruobo commented Apr 20, 2016

Some days ago I try to use mnist data set make a single image to predict, under the help of @clcarwin , who give me some useful advise. Now I try to use the model to train my own data, some gray scale images just like mnist. The shape is 256*256, 3 classes. When I use mlp I changed datashape as (65536,),
I got this message: mxnet.base.MXNetError: Invalid Parameter format for data_shape expect Shape(tuple) but value='65536'
When I use lenet, datashape as (1,256,256), it worked.
But I use the code to make simple image predict , it also crashed.
This is my predict code :

data = cv2.imread(dir_image) # check if the size of image is 256*256
data = data.transpose((2,0,1))
data = data[0:1,:,:]
print data.shape # (1,256, 256)

data = np.reshape(data,(1,1,256,256)) # for lenet (batchsize, ch, height, width)

data = np.reshape(data,(1,784)) # for mlp

model = mx.model.FeedForward.load(prefix, iteration)
dataiter = mx.io.NDArrayIter(data)
r = model.predict(dataiter)

and this is the error message:
mxnet.base.MXNetError: [11:36:00] src/ndarray/ndarray.cc:227: Check failed: from.shape() == to->shape() operands shape mismatch

If someone could give me some advise I will be very thankful, I have been puzzled by these problems some days.....

@tqchen
Copy link
Member

tqchen commented Apr 26, 2016

It might be helpful to print out the shape outputed from your data iterator. and look at backtrace where this error throws out

It is likely due to different data shape from those allocated into the executor

@phunterlau
Copy link
Contributor

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

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

No branches or pull requests

3 participants