ImportError: cannot import name ‘dtensor‘ from ‘tensorflow.compat.v2.experimental‘报错

一、错误分析

出现这个问题原因在于tensorflow和keras版本不匹配,keras的版本太高了,需要降低到和tensorflow版本一致。

二、解决步骤

1.首先查看自己电脑的keras版本:pip show keras

上图中,我的tensorflow版本为2.6,keras版本为2.12.0,

 2.使用  pip install keras==2.6

 如果出现错误信息,其实是可以忽略的,或者挨个pip install xxxx即可:

tensorflow 2.6.0 requires clang~=5.0, which is not installed.
tensorflow 2.6.0 requires absl-py~=0.10, but you have absl-py 1.3.0 which is incompatible.
tensorflow 2.6.0 requires flatbuffers~=1.12, but you have flatbuffers 20210226132247 which is incompatible.

猜你喜欢

转载自blog.csdn.net/linxi4165/article/details/130463805