Displaying activation maps with keras on a custom model

Viewed 81

This is the model I would like to display the activation maps. My own model:

base_model = keras.applications.Xception(weights='imagenet',
                                         input_shape=dimensions,
                                         include_top=False)

base_model.trainable = True
inputs = keras.Input(shape=dimensions)
x = base_model(inputs)
x = keras.layers.GlobalAveragePooling2D()(x)
outputs = keras.layers.Dense(len(classes), activation='sigmoid')(x)
model = keras.Model(inputs, outputs)

And this is the tutorial I am following

And finally, here I have the colab with the working code (you have to upload your own image)

But when I try to display the activation maps with my own model, I get the following error:

Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 320, 320, 3), 
dtype=tf.float32, name='input_1'), name='input_1', description="created by layer 'input_1'") at layer "block1_conv1". 
The following previous layers were accessed without issue: []
0 Answers
Related