aidenwilson
aidenwilson

Reputation: 41

Why does the numpy dot product function returns an error when passed two TensorFlow Variable objects?

import tensorflow as tf
import numpy as np

a = tf.Variable([[12, 13], [12, 13]])
b = tf.Variable([[12, 13], [12, 13]])

print(np.dot(a, b))

The above code returns the error:

TypeError: __array__() takes 1 positional argument but 2 were given.

I understand that TensorFlow has a builtin method for matrix multiplication, but I was curious why the np.dot method does not work, specifically with tensorflow Variable objects (it seems to do fine with tensorflow.constant objects).

Other methods, such as np.square, np.sqrt, etc. all work with this, but it seems that only np.dot in particular does not.

Edit: I was wondering why these objects in particular do not work when passed to the np.dot function. I realize that there are a variety of ways to find the dot product between two tf.Variable objects

Upvotes: 2

Views: 141

Answers (1)

jkr
jkr

Reputation: 19300

This appears to be a bug in TensorFlow. Please see https://github.com/tensorflow/tensorflow/issues/46563. As of July 12, 2021, there is no explanation on that github issue of what causes the problem.

Upvotes: 3

Related Questions