Hi experts,
When running TF Advance Techniques C3W4 Lab 1 (Class Activation Maps with Fashion MNIST) after training the model, and executing the follow cell:
cam_model = Model(inputs=model.input,outputs=(model.layers[-3].output,model.layers[-1].output))
cam_model.summary()
Got the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-27-fe19a5d35706> in <cell line: 2>()
1 # same as previous model but with an additional output
----> 2 cam_model = Model(inputs=model.input,outputs=(model.layers[-3].output,model.layers[-1].output))
3 # model.summary()
4 # cam_model = Model( inputs=model.input, outputs=( [model.layers[-3].output, model.layers[-1].output] ) )
5 cam_model.summary()
1 frames
/usr/local/lib/python3.10/dist-packages/keras/src/ops/operation.py in _get_node_attribute_at_index(self, node_index, attr, attr_name)
283 """
284 if not self._inbound_nodes:
--> 285 raise ValueError(
286 f"The layer {self.name} has never been called "
287 f"and thus has no defined {attr_name}."
ValueError: The layer sequential_4 has never been called and thus has no defined input.
There is a typo in that cell which should be referencing model.inputs with a missing trailing ‘s’:
cam_model = Model(inputs=model.inputs,outputs=(model.layers[-3].output,model.layers[-1].output))
cam_model.summary()
Just realized similar typo with Lab 2 as well.