C1_W4_Lab_1_image_generator_no_validation Error

For the notebook: C1_W4_Lab_1_image_generator_no_validation.ipynb

In the final section, ‘Visualizing Intermediate Representations’, you get an error when running the cell.

After doing some research, the error I was encountering, ValueError: The layer sequential has never been called and thus has no defined input, typically occurs when you’re trying to create a new model based on an existing Sequential model that hasn’t been built yet. This happens because the Sequential model needs to have been called with an input before its input and output shapes are defined.

I tried the suggestion of adding a dummy input, but was not successful. Any advice?

Full error below:

ValueError Traceback (most recent call last)
in <cell line: 13>()
11 # the first.
12 successive_outputs = [layer.output for layer in model.layers[1:]]
—> 13 visualization_model = tf.keras.models.Model(inputs = model.input, outputs = successive_outputs)
14
15 # Prepare a random input image from the training set.

1 frames
/usr/local/lib/python3.10/dist-packages/keras/src/ops/operation.py in input(self)
252 Input tensor or list of input tensors.
253 “”"
→ 254 return self._get_node_attribute_at_index(0, “input_tensors”, “input”)
255
256 @property

/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 has never been called and thus has no defined input.

Have you perhaps not included a input layer into the model, check out this page:

also please mention if anyone is doing the assignment on their local colab or jupyter as I am seeing recently the error seem to be related to this.

If codes were in coursera provided platform, then surely staff can look into.