I get this error and have no idea what is wrong with my code.
I already tried to restart the kernel and rerun all the cells without success.
Every hint or help is appreciated!
ValueError Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(op_type_name, name, **keywords)
469 as_ref=input_arg.is_ref,
→ 470 preferred_dtype=default_dtype)
471 except TypeError as err:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types)
1474 "Tensor conversion requested dtype %s for Tensor with dtype %s: r"
→ 1475 (dtype.name, value.dtype.name, value))
1476 return value
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: <tf.Tensor ‘kernel:0’ shape=(90, 256) dtype=float32>
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
in
----> 1 inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)
in music_inference_model(LSTM_cell, densor, Ty)
38 for t in range(Ty):
39 # Step 2.A: Perform one step of LSTM_cell. Use “x”, not “x0” (≈1 line)
—> 40 a, _, c = LSTM_cell(inputs=x, initial_state = [a, c])
41
42 # Step 2.B: Apply Dense layer to the hidden state output of the LSTM_cell (≈1 line)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent.py in call(self, inputs, initial_state, constants, **kwargs)
707 # Perform the call with temporarily replaced input_spec
708 self.input_spec = full_input_spec
→ 709 output = super(RNN, self).call(full_input, **kwargs)
710 # Remove the additional_specs from input spec and keep the rest. It is
711 # important to keep since the input spec was populated by build(), and
/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)
1115 try:
1116 with ops.enable_auto_cast_variables(self._compute_dtype_object):
→ 1117 outputs = call_fn(cast_inputs, *args, **kwargs)
1118
1119 except errors.OperatorNotAllowedInGraphError as e:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent_v2.py in call(self, inputs, mask, training, initial_state)
1181 else:
1182 (last_output, outputs, new_h, new_c,
→ 1183 runtime) = lstm_with_backend_selection(**normal_lstm_kwargs)
1184
1185 states = [new_h, new_c]
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent_v2.py in lstm_with_backend_selection(inputs, init_h, init_c, kernel, recurrent_kernel, bias, mask, time_major, go_backwards, sequence_lengths, zero_output_for_mask)
1556 # grappler will kick in during session execution to optimize the graph.
1557 last_output, outputs, new_h, new_c, runtime = defun_standard_lstm(
→ 1558 **params)
1559 function.register(defun_gpu_lstm, **params)
1560
/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py in call(self, *args, **kwargs)
2826 “”“Calls a graph function specialized to the inputs.”""
2827 with self._lock:
→ 2828 graph_function, args, kwargs = self._maybe_define_function(args, kwargs)
2829 return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
2830
/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs)
3211
3212 self._function_cache.missed.add(call_context_key)
→ 3213 graph_function = self._create_graph_function(args, kwargs)
3214 self._function_cache.primary[cache_key] = graph_function
3215 return graph_function, args, kwargs
/opt/conda/lib/python3.7/site-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
3073 arg_names=arg_names,
3074 override_flat_arg_shapes=override_flat_arg_shapes,
→ 3075 capture_by_value=self._capture_by_value),
3076 self._function_attributes,
3077 function_spec=self.function_spec,
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)
984 _, original_func = tf_decorator.unwrap(python_func)
985
→ 986 func_outputs = python_func(*func_args, **func_kwargs)
987
988 # invariant: func_outputs
contains only Tensors, CompositeTensors,
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent_v2.py in standard_lstm(inputs, init_h, init_c, kernel, recurrent_kernel, bias, mask, time_major, go_backwards, sequence_lengths, zero_output_for_mask)
1313 input_length=(sequence_lengths
1314 if sequence_lengths is not None else timesteps),
→ 1315 zero_output_for_mask=zero_output_for_mask)
1316 return (last_output, outputs, new_states[0], new_states[1],
1317 _runtime(_RUNTIME_CPU))
/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 “”“Call target, and fall back on dispatchers if there is a TypeError.”""
200 try:
→ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/backend.py in rnn(step_function, inputs, initial_states, go_backwards, mask, constants, unroll, input_length, time_major, zero_output_for_mask)
4212 # the value is discarded.
4213 output_time_zero, _ = step_function(
→ 4214 input_time_zero, tuple(initial_states) + tuple(constants))
4215 output_ta = tuple(
4216 tensor_array_ops.TensorArray(
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent_v2.py in step(cell_inputs, cell_states)
1289 c_tm1 = cell_states[1] # previous carry state
1290
→ 1291 z = K.dot(cell_inputs, kernel)
1292 z += K.dot(h_tm1, recurrent_kernel)
1293 z = K.bias_add(z, bias)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 “”“Call target, and fall back on dispatchers if there is a TypeError.”""
200 try:
→ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/backend.py in dot(x, y)
1829 out = sparse_ops.sparse_tensor_dense_matmul(x, y)
1830 else:
→ 1831 out = math_ops.matmul(x, y)
1832 return out
1833
/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py in wrapper(*args, **kwargs)
199 “”“Call target, and fall back on dispatchers if there is a TypeError.”""
200 try:
→ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py in matmul(a, b, transpose_a, transpose_b, adjoint_a, adjoint_b, a_is_sparse, b_is_sparse, name)
3253 else:
3254 return gen_math_ops.mat_mul(
→ 3255 a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
3256
3257
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py in mat_mul(a, b, transpose_a, transpose_b, name)
5640 _, _, _op, _outputs = _op_def_library._apply_op_helper(
5641 “MatMul”, a=a, b=b, transpose_a=transpose_a, transpose_b=transpose_b,
→ 5642 name=name)
5643 _result = _outputs[:]
5644 if _execute.must_record_gradient():
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(op_type_name, name, **keywords)
504 "%s type %s of argument ’s'."
505 (prefix, dtypes.as_dtype(attrs[input_arg.type_attr]).name,
→ 506 inferred_from[input_arg.type_attr]))
507
508 types = [values.dtype]
TypeError: Input ‘b’ of ‘MatMul’ Op has type float32 that does not match type int32 of argument ‘a’.