keras-team / autokeras

AutoML library for deep learning
http://autokeras.com/
Apache License 2.0
9.15k stars 1.4k forks source link

ValueError: could not broadcast input array #144

Closed marooncn closed 6 years ago

marooncn commented 6 years ago

Hi, I use autokeras to train a model using my image data. What I want to do is comparing different classifiers using little data. So I try to search a NN model with autokeras. I use load_image_dataset to load image data. But when I run it, there is an error:

Traceback (most recent call last): File "autoCNNclassifier.py", line 31, in train_model() File "autoCNNclassifier.py", line 15, in train_model images_path=train_data_dir) File "/usr/local/lib/python3.5/dist-packages/autokeras/image_supervised.py", line 108, in load_image_dataset x = read_images(img_file_name, images_path) File "/usr/local/lib/python3.5/dist-packages/autokeras/image_supervised.py", line 86, in read_images return np.asanyarray(x_train) File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 544, in asanyarray return array(a, dtype, copy=False, order=order, subok=True) ValueError: could not broadcast input array from shape (256,256,1) into shape (256,256)

autoCNNclassifier.py and the dataset can be found here. What's the matter? Thank you.

mariolys07 commented 6 years ago

I'm having the same problem.

huyhoang17 commented 6 years ago

Should u squeezed your image? Try this method to remove single dimension in image. https://docs.scipy.org/doc/numpy/reference/generated/numpy.squeeze.html

soerface commented 6 years ago

@marooncn @mariolys07 The problem seems to occur when you have black and white images. With np.repeat I could work around the issue, copying the last channel two times. See my commit above, not sure if this is the way to go. I think we should look forward to fixing #204 instead of tinkering with this function.

marooncn commented 6 years ago

@soerface Thank you, your solution is correct. After three days run the final result is about 82% on my dataset. It's much higher than a simple neural network I designed which the precision is 68.75%.