Incompatible shapes to fit model in lecture Food Vision Big (section 9) #515
Unanswered
ivan-marroquin
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I notice in tensorflow 2.11, the use of these commands:
'# Map preprocessing function to training (and parallelize)
train_data= train_data.map(map_func= preprocess_img, num_parallel_calls= tf.data.AUTOTUNE)
Shuffle train_data and turn it into batches and prefetch it (load it faster)
train_data= train_data.shuffle(buffer_size= 1000).batch(batch_size= 32).prefetch(buffer_size= tf.data.AUTOTUNE)
Map preprocessing function to test data
test_data= test_data.map(map_func= preprocess_img, num_parallel_calls= tf.data.AUTOTUNE).batch(batch_size= 32).prefetch(tf.data.AUTOTUNE).cache()
'
produce data with these shapes:
(<PrefetchDataset element_spec=(TensorSpec(shape=(None, None, 224, 224, 3), dtype=tf.float32, name=None), TensorSpec(shape=(None, None), dtype=tf.int64, name=None))>,
<CacheDataset element_spec=(TensorSpec(shape=(None, None, 224, 224, 3), dtype=tf.float32, name=None), TensorSpec(shape=(None, None), dtype=tf.int64, name=None))>)
Although I am able to compile the feature extraction model - following the code in the video, I get this error message when I want to fit the model:
'
model.fit(train_data, steps_per_epoch= len(train_data),
validation_data= test_data, validation_steps= int(0.15 * len(test_data)),
callbacks= [create_tensorboard_callback(dir_name= 'training_loss', experiment_name=
'efficientb0_101_classes_all_data_feature_extract'),
model_checkpoint])
'
ValueError: Input 0 of layer "model_1" is incompatible with the layer: expected shape=(None, 224, 224, 3), found shape=(None, None, 224, 224, 3)
Any suggestions?
Thanks,
Ivan
Beta Was this translation helpful? Give feedback.
All reactions