The 2nd LSTM call throw an incorrect ndim error. The only code to specify shape is the line of the Input call, where I passed in the input_shape “(4,)”. Is there anything I missed?
ValueError Traceback (most recent call last)
in
28
29
—> 30 Emojify_V2_test(Emojify_V2)
in Emojify_V2_test(target)
20
21 maxLen = 4
—> 22 model = target((maxLen,), word_to_vec_map, word_to_index)
23
24 assert type(model) == Functional, “Make sure you have correctly created Model instance which converts "sentence_indices" into "X"”
in Emojify_V2(input_shape, word_to_vec_map, word_to_index)
37 # The returned output should be a single hidden state, not a batch of sequences.
38 print(X.shape)
—> 39 X = LSTM(units=128, return_sequences=True)(X)
40 # Add dropout with a probability of 0.5
41 X = Dropout(rate=0.5)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent.py in call(self, inputs, initial_state, constants, **kwargs)
661
662 if initial_state is None and constants is None:
→ 663 return super(RNN, self).call(inputs, **kwargs)
664
665 # If any of initial_state
or constants
are specified and are Keras
/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)
178 ‘expected ndim=’ + str(spec.ndim) + ‘, found ndim=’ +
179 str(ndim) + '. Full shape received: ’ +
→ 180 str(x.shape.as_list()))
181 if spec.max_ndim is not None:
182 ndim = x.shape.ndims
ValueError: Input 0 of layer lstm_17 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 128]