tensorflow-deep-learning icon indicating copy to clipboard operation
tensorflow-deep-learning copied to clipboard

InvalidArgumentError: Graph execution error: Video 136, Model_10

Open kelixirr opened this issue 2 years ago • 2 comments

My Code Of The Model After Data Augmentation. Model cloning was not working on my TensorFlow version for unknown reasons so I used this

model_10 = Sequential([
 Conv2D(10, 3, input_shape=(224, 224, 3)),
 Activation(activation='relu'),
 Conv2D(10, 3, activation='relu'),
 MaxPool2D(),
 Conv2D(10, 3, activation='relu'),
 Conv2D(10, 3, activation='relu'),
 MaxPool2D(),
 Flatten(),
 Dense(10, activation="softmax")                     
])

model_10.compile(loss='categorical_crossentropy',
                 optimizer=tf.keras.optimizers.Adam(),
                 metrics=['accuracy'])

history_10 = model_10.fit(train_data_augmented, 
                          epochs=5, 
                          steps_per_epoch=len(train_data_augmented),
                          validation_data=test_data,
                          validation_steps=len(test_data))

Error Message

input to reshape is a tensor with 9412800 values, but the requested shape requires a multiple of 28090
[[{{node sequential_9/flatten_9/Reshape}}]] [Op:__inference_train_function_20412]

kelixirr avatar Jun 02 '22 10:06 kelixirr

@kelixirr Used this code, because copying also didn't work for me:

train_datgen_augmented = ImageDataGenerator(rescale=1/255.,
                                           rotation_range=0.55,
                                           zoom_range=0.2,
                                           width_shift_range=0.1,
                                           height_shift_range=0.1,
                                           horizontal_flip=True)

train_datgen_augmented = train_datgen_augmented.flow_from_directory(train_dir,
                                        target_size=(244, 244),
                                        batch_size=32,
                                        class_mode="categorical")

model_10 = Sequential([
    Conv2D(10, 3, input_shape=(224, 224, 3)),
    Activation(activation="relu"),
    Conv2D(10, 3, activation="relu"),
    MaxPool2D(),
    Conv2D(10, 3, activation="relu"),
    Conv2D(10, 3, activation="relu"),
    MaxPool2D(),
    Flatten(),
    Dense(10, activation="softmax")
], "model_10")

model_10.compile(loss="categorical_crossentropy",
               optimizer=Adam(),
               metrics=["accuracy"])

history_10 = model_10.fit(train_data_augmented,
                       epochs=5,
                       steps_per_epoch=len(train_data_augmented),
                       validation_data=test_data,
                       validation_steps=len(test_data))

catbears avatar Jun 20 '22 09:06 catbears

Hi @kelixirr, did you manage to fix your error?

It looks like the input shapes to your data are off, I'd inspect the shapes of the data going into the model and see if there are mismatches.

And I'd also make sure the input and output shapes of each layer in your architecture line up.

mrdbourke avatar Jun 23 '22 09:06 mrdbourke