BEGIN:

解决方案:更换更低版本(具体操作如下)

打开cmd,运行

pip list

查询结果如下,找到tensorflow我这里版本为2.0.0a0

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 修改版本为1.5,执行如下命令

pip3 install tensorflow==1.5

结果

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

 

 

 有点问题,更新一下:

pip install update tensorflow

结果如下:

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

 

 用pip list查看一下,这时候版本为1.5.0:

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

这时候我这里出现了另一个隐藏的warning:

FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])

更改numpy版本,我这里原先是1.17.0,改为1.16

pip3 install numpy==1.16

额……还是有问题,老办法

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

pip install update numpy

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

 

 

 最后

pip list

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

 

 

 好啦,问题解决了!

 

AttributeError: module 'tensorflow' has no attribute 'truncated_normal'

 

END.