TensorFlow module ‘tensorflow‘ has no attribute ‘Session‘ 问题解决
问题描述
在初次尝试tensorflow 的时候遇到类似下面的问题:
module ‘tensorflow’ has no attribute ‘placeholder’
module ‘tensorflow’ has no attribute 'Session’
问题解决
导致该问题的原因是:
tensorflow的 V1 版本和V2版本不能直接兼容,需要在其前置中加入些代码设置环境:
import tensorflow.compat.v1 as tf
这个时候,如果你使用了placeholder的话,
原创
2020-12-03 16:20:17 ·
3419 阅读 ·
0 评论