I’m trying to solve the first exercise of the 3rd assignment of week 1 in the Sequence Models course. I’m having some problems with the code. I won’t put my code as per the code of honor, but I’m getting the following error in the reshape layer:
InvalidArgumentError: Input to reshape is a tensor with 2 values, but the requested shape has 180 [Op:Reshape]
In the previous step, I have sliced X to a shape=(None, 90), and I’m passing the tuple (1, n_values) as an argument to the reshaper layer.
Instruction says, Step 2.B: Use reshaper to reshape x to be (1, n_values) (≈1 line). It means you have to pass x which is the shape of (None, 90) as an argument to the reshaper, and then it will return the (1, n_values) shape.
the reshaper for actually returns x as (None,1,n_values), in my case (None,1,90). Is this right or I should have (1,n_values)
When i run the output = summary(model)
I get the following error:
AttributeError Traceback (most recent call last)
<ipython-input-53-2ad560a25ebc> in <module>
2
3 # UNIT TEST
----> 4 output = summary(model)
5 comparator(output, djmodel_out)
~/work/W1A3/test_utils.py in summary(model)
34 result = []
35 for layer in model.layers:
---> 36 descriptors = [layer.__class__.__name__, layer.output_shape, layer.count_params()]
37 if (type(layer) == Conv2D):
38 descriptors.append(layer.padding)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in output_shape(self)
2190 'ill-defined for the layer. '
2191 'Use `get_output_shape_at(node_index)` '
-> 2192 'instead.' % self.name)
2193
2194 @property
AttributeError: The layer “reshape” has multiple inbound nodes, with different output shapes. Hence the notion of “output shape” is ill-defined for the layer. Use get_output_shape_at(node_index) instead.
I have the same output as you have. I added some print statements in my code and below are a few lines from a long loop:
Shape of x after Step 2.A: (None, 90)
Shape of x after Step 2.B: (None, 1, 90)
You can add print statement to check yours:
print(f"Shape of x after Step 2.A: {x.shape}")
# Step 2.B: Use reshaper to reshape x to be (1, n_values) (≈1 line)
x = None
print(f"Shape of x after Step 2.B: {x.shape}")
The shape of x in my code is different, it’s (30, 90) after step 2.A and (30, 1, 90) after step 2.B, yet i get the same exact error and can’t find a solution