Reputation: 1
I'm trying to make a classification network for IDing pictures from the cifar10 dataset. When I try to use the summary() function, I keep getting this error.
ValueError Traceback (most recent call last)
Cell In[267], line 4
1 #base_model.summary()
2 #top_model.summary()
3 #print(base_model.output_shape)
----> 4 model2.summary()
File c:\Users\noahc\anaconda3\Lib\site-packages\keras\src\utils\traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
119 filtered_tb = _process_traceback_frames(e.__traceback__)
120 # To get the full stack trace, call:
121 # `keras.config.disable_traceback_filtering()`
--> 122 raise e.with_traceback(filtered_tb) from None
123 finally:
124 del filtered_tb
File c:\Users\noahc\anaconda3\Lib\site-packages\optree\ops.py:747, in tree_map(func, tree, is_leaf, none_is_leaf, namespace, *rests)
745 leaves, treespec = _C.flatten(tree, is_leaf, none_is_leaf, namespace)
746 flat_args = [leaves] + [treespec.flatten_up_to(r) for r in rests]
--> 747 return treespec.unflatten(map(func, *flat_args))
ValueError: Undefined shapes are not supported.
Here's the code...
import tensorflow as tf
from keras.applications import VGG16
base_model = VGG16(weights='imagenet', include_top=False, input_shape=(32, 32, 3))
top_model = tf.keras.Sequential([
layers.Flatten(input_shape=base_model.output_shape[1:]),
layers.Dense(10, activation='softmax')
])
for layer in base_model.layers[:10]:
layer.trainable = False
model2 = tf.keras.models.Sequential([
base_model,
top_model
])
model2.summary() # Error Occurs Here
I've done a summary for the base and top model and it works fine. But when I test model2 the error occurs. Have no idea why. Not sure what it means by 'undefined' shapes. Not sure what else to try. The summary worked when I only took the first 11 or 15 layers of the vgg16. I've heard it might be a problem with the python version itself, but idk...
Upvotes: 0
Views: 91
Reputation: 1
I just removed input_shape=base_model.output_shape[1:]
and it worked.
Upvotes: 0