Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 3 array(s), but instead got the following list of 2 arrays. #55

Open
dassima opened this issue Mar 27, 2018 · 0 comments

Comments

@dassima
Copy link

dassima commented Mar 27, 2018

Hi.
I get the error:

Begin training model, 10000 epochs.
Epoch 1/10000
Traceback (most recent call last):
  File "main.py", line 60, in <module>
    main(None)
  File "main.py", line 57, in main
    period = 1)])
  File "/home/diana/Documents/VirtualNN/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "/home/diana/Documents/VirtualNN/local/lib/python2.7/site-packages/keras/engine/training.py", line 2114, in fit_generator
    class_weight=class_weight)
  File "/home/diana/Documents/VirtualNN/local/lib/python2.7/site-packages/keras/engine/training.py", line 1826, in train_on_batch
    check_batch_axis=True)
  File "/home/diana/Documents/VirtualNN/local/lib/python2.7/site-packages/keras/engine/training.py", line 1407, in _standardize_user_data
    exception_prefix='input')
  File "/home/diana/Documents/VirtualNN/local/lib/python2.7/site-packages/keras/engine/training.py", line 88, in _standardize_input_data
    '...')
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 3 array(s), but instead got the following list of 2 arrays: [array([[[[0.5803922 , 0.5882353 , 0.5921569 , ..., 0.53333336,
          0.5294118 , 0.5254902 ],
         [0.5882353 , 0.5921569 , 0.59607846, ..., 0.5372549 ,
          0.53333336, 0.5294118 ],
   ...

I am using ImageDataGenerator and I create my dataset like this because the input of my gan are noise and images, labels are images also:

train_datagen = ImageDataGenerator(rescale = 1./ 255, data_format = "channels_first")
    val_datagen   = ImageDataGenerator(rescale = 1./ 255, data_format = "channels_first")

    train_generator = train_datagen.flow_from_directory(train_folder, target_size = (img_rows, img_cols), batch_size = 1, class_mode = None)

    validation_generator = val_datagen.flow_from_directory(valid_folder, target_size = (img_rows, img_cols), batch_size = 1, class_mode = None)


    def train_generator_func():
        while True:
            train_generat       = train_generator.next()
            train_generat_label = train_generator.next()
            noise               = np.random.normal(size = (1, 8, 8, 100))
#there is the same iterator because I want to have pairs of images

            yield [train_generat,noise], [train_generat_label]
                         
    def val_generator_func():
        while True:
            valid_generat       = validation_generator.next()
            valid_generat_label = validation_generator.next()
            noise               = np.random.normal(size = (1, 8, 8, 100))
        
            yield [valid_generat,noise], [valid_generat_label]

    train_gen      = train_generator_func()
    validation_gen = val_generator_func()
    
    return train_gen, validation_gen

What do you think I get this error, because from my understanding i generate input, output shape for data_generator.

@dassima dassima changed the title TypeError: can only concatenate tuple (not "int") to tuple ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 3 array(s), but instead got the following list of 2 arrays. Mar 27, 2018
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

No branches or pull requests

1 participant