因为白天上班,晚上才有点时间安装,所以花了两天时间,把教程做个记录,也算把踩过的坑记录下。
首先anaconda安装,网上的教程基本说的很全面了这个是我用的。
tensorflow真是耗费了我大量时间,按照这里来
这个教程值得注意的点是他的测试代码有误,换这个
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
x=tf.constant(3)
y=tf.constant(2)
z=x+y
sess=tf.compat.v1.Session()
print(sess.run(z))
原代码的tf.Session适配于tensorflow1.0,这个报错是AttributeError: module ‘tensorflow’ has no attribute ‘Session’。所以改成
sess=tf.compat.v1.Session()
,但是单纯修改后会报错The Session graph is empty. Add operations to the graph before calling run()。
所以添加
tf.compat.v1.disable_eager_execution()
除此以外,安装tensorflow似乎还得是python3.5.当时我把我电脑里的3.6删了,换了这个,结果pycharm一直报错:ImportError: Module use of python35.dll conflicts with this,所以修改了pycharm的python版本,链接在这里
最后,如果pychram显示connecting console,看这里
基本问题就这些,水平有限,如有不足,请多多指正。