How to Fix TypeError: ‘tensorflow.python.framework.ops.EagerTensor’ object is not callable

To fix the TypeError: ‘tensorflow.python.framework.ops.EagerTensor’ object is not callable, use .numpy() method to convert the EagerTensor to a NumPy array and then perform the further operation.

This error occurs when you try to call a TensorFlow EagerTensor object as if it were a function or method.

Reproduce the error

Reproduce the 'tensorflow.python.framework.ops.EagerTensor' object is not callable

import tensorflow as tf

tenr = tf.constant([11, 21, 19])

output = tenr()

print(output)

Output

TypeError: 'tensorflow.python.framework.ops.EagerTensor' object is not callable

How to fix it?

Fixing the 'tensorflow.python.framework.ops.EagerTensor' object is not callable

import tensorflow as tf
import numpy as np

tenr = tf.constant([11, 21, 19])

output = np.square(tenr.numpy())

print(output)

Output

[121 441 361]

That’s it!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.