Problem: AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike' solution

Recently, a problem occurred when I used keras to run code training: AttributeError: module 'tensorflow.python.framework.ops' has no attribute '_TensorLike'. There are endless solutions on the Internet. I have tried a lot and failed to solve my own problem. I will try later I gave my own solution, and the summary is as follows:
The problem is as follows:

insert image description here

The main reason for this problem is that the keras version and tensorflow-gpu version are not applicable. For example, my original tensorflow-gpu version is 2.4.0, and the keras version is 2.3.1, see below:

insert image description here
Later, I uninstalled the 2.3.1 version of keras, re-downloaded the 2.4.3 version of keras, and then ran the code without any problem, see below:

pip uninstall keras          ## 卸载原来安装好的2.3.1版本
pip install keras==2.4.3 -i https://mirrors.aliyun.com/pypi/simple/ ## 安装2.4.3版本的keras

insert image description here
insert image description here

The above is that I downloaded the keras 2.4.3 version and the tensorflow-gpu 2.4.0 version to run normally after it is applicable. It is estimated that other keras versions higher than 2.3.1 are also applicable. Scholars try it by themselves. I hope you can solve the problem as soon as possible. If my method can help you solve the same problem, please support me a lot, thank you!

Guess you like

Origin blog.csdn.net/qq_40280673/article/details/125619983