Tensorflow 学习笔记

来源:互联网 发布:深圳网络安全工程师 编辑:程序博客网 时间:2024/06/08 10:48

tensorflow安装:

CPU版本
pip install tensorflow
GPU版本
pip install tensorflow-gpu
由于某些原因,国内使用pip安装速度慢,需要手动更换国内源,自行百度,大概就是创建一个pip.conf文件,内容包含国内源
https://segmentfault.com/a/1190000000375848

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
需要创建或修改配置文件(一般都是创建),

linux的文件在~/.pip/pip.conf

windows在%HOMEPATH%\pip\pip.ini

[global]index-url = http://pypi.douban.com/simple[install]trusted-host=pypi.douban.com

win

Installing with Anaconda

1.下载地址
https://www.continuum.io/downloads
安装时选择for all user,路径中不能含有中文,尽量使用默认目录,其他一律默认选项。
2.Create a conda environment named tensorflow by invoking the following command:
打开terminal或powershell 输入
C:> conda create -n tensorflow python=3.5
输入
python -V
pip -V
检查是否安装好,如果显示了版本号,则安装成功
如果出现找不到Python和pip的情况,说明没有将Python和pip的安装目录添加到系统的环境变量中,参考http://blog.csdn.net/zyx19950825/article/details/52469813

3.Activate the conda environment by issuing the following command:

C:> activate tensorflow(tensorflow)C:>  # Your prompt should change 

4.Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:

(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command (on a single line):
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
5.检查

import tensorflow as tfhello = tf.constant('Hello, TensorFlow!')sess = tf.Session()print(sess.run(hello))a = 11b=77ab = a*bprint(ab)

检查是否正确安装了GPU版本
https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c
在terminal中cd 到文件目录,运行脚本
python tensorflow_self_check.py
如下:

PS D:\downloads\TFselfCheck> python tensorflow_self_check.pyTensorFlow successfully installed.The installed version of TensorFlow includes GPU support.

ubuntu

先按照[问题汇总]ubuntu16.04+cuda8.0+cudnn+opencv3.2+caffe+tensorflow
配置电脑,装nVidia驱动cuda8.0,以及下载cudnn6.0(版本一定要一致)

安装anaconda等参考
https://www.tensorflow.org/install/install_linux#InstallingAnaconda

使用

IDE:

pycharm:

http://www.jetbrains.com/pycharm/download/#section=windows
编译环境配置:
http://blog.csdn.net/caicaiatnbu/article/details/72632693

安装numpy+scipy+matlotlib+scikit-learn及问题解决
http://www.cnblogs.com/eastmount/p/5052871.html

pycharm快捷键及使用技巧
https://www.zhihu.com/question/37787004?sort=created

这里写图片描述

原创粉丝点击