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
Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays #9475
Comments
What's the shape of X_good, X_bad, X_good_id & X_bad_id ?? |
(52, 250, 250, 3) |
Try changing the output layer to |
Getting Same error. |
It is multi-input and multi-output model. The algorithm takes pair of images as input at a time. |
While running this code
|
No getting same error |
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays: [array([['1'], |
you need to concatenate X_good_id and X_bad_id using numpy. your model.fit line is indicating that your model as multi-output So instead, try doing the following
|
Input: it should take two images at a time (good and bad image). It should produce two outputs The code is given below
`X_good = X_good.astype('float32') X_good /= 255 `visible1 = Input(shape=(250,250,3)) visible2 = Input(shape=(250,250,3)) merge = concatenate([flat1, flat2]) interpretation modelhidden1 = Dense(10, activation='relu')(merge)
It is showing the below error. Could you please tell how to correct this? `--------------------------------------------------------------------------- /home/vinay/securetensor/local/lib/python2.7/site-packages/keras/engine/training.pyc in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs) /home/vinay/securetensor/local/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size) /home/vinay/securetensor/local/lib/python2.7/site-packages/keras/engine/training.pyc in _standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix) ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays: [array([['1'], |
@vinayakumarr I think I misunderstood what you wanted to do with the model. If you do want 2 outputs, then you need to specify it in the Example:
then you can call fit just like you did
|
It works. But I have a doubt. My problem is that Input: it should take two images at a time (good and bad image). It should produce two outputs. Whether the followed method is correct? |
@vinayakumarr Can you elaborate more? If there are no more technical issues then please close the issue |
The code is already given above. It works fine. When i give model.predict([X_good, X_bad]) [array([[1.], When I swap the inputs like give below The model should give same output even if i revrse the inputs |
@vinayakumarr |
So then there is no problem in the network am I right? Also, I can reverse the inputs during the testing stage? |
The code is given below. It takes two images, 33 images from the first category and 33 images from another category. At a time two input is passed and the network should tell whether it belongs to the first or second category. import cv2 X_bad = [] import numpy as np import numpy as np import numpy as np X_good /= 255 visible2 = Input(shape=(250,250,3)) merge = concatenate([flat1, flat2]) interpretation modelhidden1 = Dense(10, activation='relu')(merge) pr is a list of list contains 33 images in one list and 33 images in another list. But it should contain only one list with 33 elements. How to do this? |
hi,im working on a sentiment analysis project with keras since im new to keras i don't have any view to solve this problem, this is my keras model: model = Sequential() model.add(Conv1D(32, kernel_size=3, activation='elu', padding='same', """ 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 1 array(s), but instead got the following list of 3 arrays: [array([[ 0.08031651, 0.05684812, 0.22872323, ..., -0.19047852...""" sorry if its such a stupid question! i know it was asked several times in the SOF but i did most of their suggestion, seems it was not practical to me since my poor knowledge about keras |
@zbokaee |
I had this trouble on a later version of tensorflow/keras, but not with an earlier version. The later version was on Sagemaker with Python 3.6, keras 2.2.4, tensorflow 1.12. The trick was to update the arrays to np.array: |
model.fit({'main_input': X_text_train, 'aux_input': X_number_train}, predicted_classes = model.predict(np.array(X_text_train)) getting following error |
Why do you send the array like this? What's the use of this? |
I think that here is correct (I change a little): |
I got similar error in semantic segmentation task, with 2 inputs and 2 outputs , is there anyone who tried similar task? how to use multi image_generator and mask_generator for the 2 inputs and outputs? |
I had the same issue and turning list of arrays to arrays solved it. e.g. do this {'main_input': np.asarray(X_text_train), 'aux_input': np.asarray(X_number_train)} |
I got similar error when i use dataloader (keras.utils.Sequence) for loading my data from dataset.
class Dataloder(keras.utils.Sequence):
valid_dataset = Dataset( valid_dataloader = Dataloder(valid_dataset, batch_size=1, shuffle=False) Y_pred = model1.predict_generator(valid_dataloader, len(valid_dataloader)) please help me to resolve this issue. Thanks in advance. |
How to fix this issue: Here is my code snippet:
At model,I fit the inputs,outputs....whenever I'm trying to predict model then return a same error
This shows, |
@Mahmood-Hoseini
Can you consult me please? |
Dear @chez8990 If I only need one output, how it comes ? Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays: please help |
I want to pass a pair (good and bad) to the CNN and while testing also I will pass a pair of images. The code is given below
The above program is giving the following error
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 2 arrays: [array(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1'...
The text was updated successfully, but these errors were encountered: