attributeerror: module ‘tensorflow.python.framework.ops’ has no attribute ‘_tensorlike’

This error was now fixed on Keras 2.4.3 :

attributeerror: module 'tensorflow.python.framework.ops' has no attribute '_tensorlike' 

However, if you are still on an older version of Keras, then try updating your Keras to 2.4.3 or a newer version or have a look at the following possible workarounds. Depending on the version of Tensorflow/Keras you are using, these solutions may help or not.

Possible solution #1

Use tensorflow.keras instead of keras when importing libraries

Possible solution #2

Redefine function is_tensor in file keras/backend/tensorflow_backend.py as follows:

from tensorflow.python.framework import tensor_util
def is_tensor(x):                                                                                                                                                      
    return tensor_util.is_tensor(x)
    #return isinstance(x, tf_ops._TensorLike) or tf_ops.is_dense_tensor_like(x)

This solution may work for various 2.x versions of Tensorflow


More Articles

How to start a new Github repo from an existing project

Assume that you have a project and you want to track it with Github. Navigate to the project folder,...

codezilla

codezilla

How to check for listening ports in Linux

Here is one of the most popular commands for troubleshooting network or specific application problem...

codezilla

codezilla

How to get octal file permissions from command line?

Sometimes we want to know the octal number representing the permission of a file like 755, 777, 664 ...

codezilla

codezilla