TypeError: The value passed to parameter 'a' is of type DataType not in the list of valid values

I have the following code:

_X = np.arange(1, 7).reshape((2, 3))
_Y = np.arange(1, 7).reshape((3, 2))

X = tf.convert_to_tensor(_X)
Y = tf.convert_to_tensor(_Y)

# Matrix multiplication
out1 = tf.matmul(X, Y)

For this, I get this error:

TypeError: Value passed to parameter 'a' has DataType int64 not in list of allowed values: float16, float32, float64, int32, complex64, complex128

I am using the latest version of Tensorflow. What could be the problem?

+4
source share
1 answer

The inputs to tf.matmul accept only these types:

a: Tensor of type float16, float32, float64, int32, complex64, complex128 and rank > 1.

Works with changing type X and Y to dtypes above.

import tensorflow as tf
import numpy as np
_X = np.arange(1, 7).reshape((2, 3))
_Y = np.arange(1, 7).reshape((3, 2))

X = tf.convert_to_tensor(_X,dtype=tf.int32)
Y = tf.convert_to_tensor(_Y,dtype=tf.int32)

# Matrix multiplication
out1 = tf.matmul(X, Y)

sess = tf.Session()
print(sess.run(out1))
+4
source

Source: https://habr.com/ru/post/1678719/


All Articles