Please help, I have been getting this error for the past few days. I think it is coming from my input and output to the model.
model = Model(inputs = embeddings, outputs = X)
TypeError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/execute.py in make_shape(v, arg_name)
210 try:
→ 211 shape = tensor_shape.as_shape(v)
212 except TypeError as e:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in as_shape(shape)
1234 else:
→ 1235 return TensorShape(shape)
1236
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in init(self, dims)
755 if isinstance(dims, (tuple, list)): # Most common case.
→ 756 self._dims = [Dimension(d) for d in dims]
757 elif dims is None:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in (.0)
755 if isinstance(dims, (tuple, list)): # Most common case.
→ 756 self._dims = [Dimension(d) for d in dims]
757 elif dims is None:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in init(self, value)
203 “an index method, got value ‘{0!r}’ with type ‘{1!r}’”
→ 204 .format(value, type(value))), None)
205 if self._value < 0:
/opt/conda/lib/python3.7/site-packages/six.py in raise_from(value, from_value)
TypeError: Dimension value must be integer or None or have an index method, got value ‘(4,)’ with type ‘<class ‘tuple’>’
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
22
23
—> 24 Emojify_V2_test(Emojify_V2)
in Emojify_V2_test(target)
16
17 maxLen = 4
—> 18 model = target((maxLen,), word_to_vec_map, word_to_index)
19
20 expectedModel = [[‘InputLayer’, [(None, 4)], 0], [‘Embedding’, (None, 4, 2), 30], [‘LSTM’, (None, 4, 128), 67072, (None, 4, 2), ‘tanh’, True], [‘Dropout’, (None, 4, 128), 0, 0.5], [‘LSTM’, (None, 128), 131584, (None, 4, 128), ‘tanh’, False], [‘Dropout’, (None, 128), 0, 0.5], [‘Dense’, (None, 5), 645, ‘linear’], [‘Activation’, (None, 5), 0]]
in Emojify_V2(input_shape, word_to_vec_map, word_to_index)
18 # Define sentence_indices as the input of the graph.
19 # It should be of shape input_shape and dtype ‘int32’ (as it contains indices, which are integers).
—> 20 sentence_indices = Input(shape=(input_shape,), dtype=‘int32’)
21
22 # Create the embedding layer pretrained with GloVe Vectors (≈1 line)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_layer.py in Input(shape, batch_size, name, dtype, sparse, tensor, ragged, **kwargs)
309 input_layer_config.update(
310 {‘batch_size’: batch_size, ‘input_shape’: shape})
→ 311 input_layer = InputLayer(**input_layer_config)
312
313 # Return tensor including _keras_history
.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_layer.py in init(self, input_shape, batch_size, dtype, input_tensor, sparse, name, ragged, **kwargs)
158 name=self.name,
159 sparse=sparse,
→ 160 ragged=ragged)
161
162 self.is_placeholder = True
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/backend.py in placeholder(shape, ndim, dtype, sparse, name, ragged)
1221 expand_composites=True)
1222 else:
→ 1223 x = array_ops.placeholder(dtype, shape=shape, name=name)
1224
1225 if context.executing_eagerly():
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in placeholder(dtype, shape, name)
3098 “eager execution.”)
3099
→ 3100 return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
3101
3102
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py in placeholder(dtype, shape, name)
6805 if shape is None:
6806 shape = None
→ 6807 shape = _execute.make_shape(shape, “shape”)
6808 _, _, _op, _outputs = _op_def_library._apply_op_helper(
6809 “Placeholder”, dtype=dtype, shape=shape, name=name)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/execute.py in make_shape(v, arg_name)
211 shape = tensor_shape.as_shape(v)
212 except TypeError as e:
→ 213 raise TypeError("Error converting %s to a TensorShape: s." (arg_name, e))
214 except ValueError as e:
215 raise ValueError("Error converting %s to a TensorShape: s." (arg_name,
TypeError: Error converting shape to a TensorShape: Dimension value must be integer or None or have an index method, got value ‘(4,)’ with type ‘<class ‘tuple’>’.