ITeye博客

Tensorflow初探

7wolfs · 2019-12-07 19:10 · python AI · 互联网 · Markdown

1、安装 tensorflow Pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple 安装时,为了加快下载资源速度,使用 i 参数,选择了国内镜像站点。

2、用helloworld代码tensorflow是否安装成功


import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello, TensorFlow!')
sess = tf.compat.v1.Session()
print(sess.run(hello))

说明: 由于tf.Session()是tf1里的写法,在tf2里已经没有该方法,需要使用兼容写法来调用,用法在示例代码中已演示。

备注: 如果使用辅助工具Anaconda,可以在国内镜像资源站点上下载。 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.0.0-Windows-x86_64.exe

参考: https://stackoverflow.com/questions/55142951/tensorflow-2-0-attributeerror-module-tensorflow-has-no-attribute-session https://www.jianshu.com/p/e2dd167d2892

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。