在已经安装anaconda环境及pip之后。
添加并设置pip配置文件:
mkdir ~/.pip
vim ~/.pip/pip.conf
pip.conf文件内容:
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
安装tensorflow
pip install tensorflow-cpu
测试tensorflow
#!/usr/local/bin/python3
import tensorflow as tf
hello = tf.constant('Hello, tf!')
sess = tf.Session()
print (sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print (sess.run(a+b))
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
result = (sess.run(product))
print (result)
sess.close()
参考:
手机扫一扫
移动阅读更方便
你可能感兴趣的文章