I am using the following code to define and compile a Keras model. Then when I print the model.summary() I am still getting unbuilt and erroneous summary. I am using Python3.10.12 and tensorflow 2.16.1. Please do not hesitate to reach out for any additional information you need.
Code to build the model
model = Sequential()
#model.add(embedding_layer) # Add embedding layer if applicable
model.add(Dense(num_dense_units, activation='relu')) # First dense layer with ReLU activation
model.add(Dense(len(set(cluster_labels)), activation='softmax')) # Output layer with softmax for multi-class classification
# Model compilation
#model.compile(loss=CategoricalCrossentropy(), optimizer=Adam(), metrics=['accuracy'])
model.compile(loss=CategoricalCrossentropy(from_logits=True), optimizer=Adam(learning_rate=0.001), metrics=['accuracy'])
Outcome of model.summary()
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type) ┃ Output Shape ┃ Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ dense (Dense) │ ? │ 0 (unbuilt) │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense_1 (Dense) │ ? │ 0 (unbuilt) │
└─────────────────────────────────┴────────────────────────┴───────────────┘
Total params: 0 (0.00 B)
Trainable params: 0 (0.00 B)
Non-trainable params: 0 (0.00 B)
None
When I run my script I get the following runtime error too, which I think is because the model is not being built correctly, as I verified other dimension related things and they are correct.
File "/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/usr/local/lib/python3.10/dist-packages/keras/src/trainers/data_adapters/__init__.py", line 120, in get_data_adapter
raise ValueError(f"Unrecognized data type: x={x} (of type {type(x)})")
ValueError: Unrecognized data type: x=[[ 0 0 0 ... 10 4 7]
[ 0 0 0 ... 10 4 7]
[ 0 0 0 ... 10 4 7]
...
[ 0 0 0 ... 1 6 30]
[ 0 0 0 ... 1 6 30]
[ 0 0 0 ... 1 6 30]] (of type <class 'numpy.ndarray'>)