打开cmd运行或者conda的prompt
1.首先创造tensorflow 1.15需要的环境
conda create -n tensorflow pip python=3.6
2.激活TensorFlow环境
activate tensorflow
3.用conda安装tensorflow
CPU版输入 conda install tensorflow=1.15.0
GPU版输入 conda install tensorflow-gpu=1.15.0(注意版本对应)
报错:
AttributeError: module ‘tensorflow‘ has no attribute
1.如果你导入Tensorflow模块的代码为:
import tensorflow
替换为:import tensorflow.compat.v1
2.如果你导入Tensorflow模块的代码为:
import tensorflow as tf
则替换为:import tensorflow.compat.v1 as tf
3.或者在调用上 import tensorflow as tf
sess=tf.compat.v1.Session()
注意tensonflow的2.x版本取消了session,所以在作数的运算时会报错,建议转化成x.numpy(),例如下列
a = tf.constant(12)
b = tf.constant(78)
c = a + b
print("c = ", c)
print("cval= ", c.numpy())
在pycharm直接import然后点下载或许也可以