Week 3 assignment 1 UNQ_C2 what is wrong with my output_layer parameters

Hi,
I tried many times on the "out = output_layer( … ) "
I used the “inputs=s, axis=-1” or “inputs=s” as parameter, but always failed.


ValueError Traceback (most recent call last)
in
34
35
—> 36 modelf_test(modelf)

in modelf_test(target)
11
12
—> 13 model = target(Tx, Ty, n_a, n_s, len_human_vocab, len_machine_vocab)
14
15 print(summary(model))

in modelf(Tx, Ty, n_a, n_s, human_vocab_size, machine_vocab_size)
44
45 # Step 2.C: Apply Dense layer to the hidden state output of the post-attention LSTM (≈ 1 line)
—> 46 out = output_layer(s,axis=-1)
47
48 # Step 2.D: Append “out” to the “outputs” list (≈ 1 line)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
924 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
925 return self._functional_construction_call(inputs, args, kwargs,
→ 926 input_list)
927
928 # Maintains info about the Layer.call stack.

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1090 # TODO(reedwm): We should assert input compatibility after the inputs
1091 # are casted, not before.
→ 1092 input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
1093 graph = backend.get_graph()
1094 # Use self._name_scope() to avoid auto-incrementing the name.

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
214 ’ incompatible with the layer: expected axis ’ + str(axis) +
215 ’ of input shape to have value ’ + str(value) +
→ 216 ’ but received input with shape ’ + str(shape))
217 # Check shape.
218 if spec.shape is not None:

ValueError: Input 0 of layer dense_2 is incompatible with the layer: expected axis -1 of input shape to have value 37 but received input with shape [None, 64]

Try just s, without the inputs= or axis arguments.

2 Likes

If that doesn’t work, it points to a problem with the ‘s’ value.

Thanks very much. issue has been solved. …