前言:
初学者接触一样新的东西,总是想先感受一下它的魅力所在。最近刚看完一些 tensorflow 的教程,想找些例子来感受一下。于是,就到 github 上搜了一些相关的案例,主要以主流的网络模型为主。本文主要是分享一个关于生成对抗网络(GAN)的应用案例,下文会附有 github 地址。
整理本文的目的还有一个:一开始我都是基于 anaconda2(python-2.7)安装的 tensorflow 和其他相关插件或框架。正好本文案例需要基于 python-3.6,于是我在同一个 ubuntu 系统上安装了 anaconda3,并基于 python-3.6 安装并配置了 tensorflow-GPU版,tflearn,keras 等深度学习相关环境。借此机会,将整个流程整理于此。
本文主要内容如下所示:
1)安装 anaconda3(同一个 ubuntu 系统下可同时安装 anaconda2 和 anaconda3)
2)基于 anaconda3(pip)安装 tensorflow、tflearn、keras
3)实践案例:CycleGAN
4)分享 ubuntu 版本的 anaconda2 和 anaconda3 安装包(最近官网比较不好下载)
Reference:
github地址:https://github.com/yangxue0827/CycleGAN-TensorFlow
anaconda2 安装包:http://pan.baidu.com/s/1eShGFKm 密码:u5a6
anaconda3 安装包:http://pan.baidu.com/s/1mij6soo 密码:2pzw
实践环境:
1)python-3.6.0
2)tensorflow-1.0.3
安装和配置实践环境:
1)安装 anaconda3:
- 下载 Anaconda3-5.0.1-Linux-x86_64.sh
- cd 到 Anaconda3-5.0.1-Linux-x86_64.sh 的目录下并执行如下命令:
bash Anaconda3-5.0.1-Linux-x86_64.sh
- 如果你的当前系统也存在多个anaconda,可以通过配置文件指定你所需的版本,如下所示:
sudo gedit ~/.bashrc // 打开配置文件进行编辑
source ~/.bashrc // 立即生效配置文件的内容
如下图所示:
2)安装 tensorflow(参考网址:http://tflearn.org/installation/)
安装过程请依次执行如下命令:
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp36-cp36m-linux_x86_64.whl
pip install $TF_BINARY_URL
安装过程中,如果遇到如下错误,请不要担心,再重新 pip 一次试试看。(可能是最近网络限制比较严重)
成功安装的提示如下所示:
hcq@hcq-home:~/softwares$ pip install $TF_BINARY_URL
Collecting tensorflow-gpu==1.1.0 from https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp36-cp36m-linux_x86_64.whl
Using cached https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp36-cp36m-linux_x86_64.whl
Requirement already satisfied: werkzeug>=0.11.10 in /home/hcq/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu==1.1.0)
Collecting protobuf>=3.2.0 (from tensorflow-gpu==1.1.0)
Downloading protobuf-3.4.0-cp36-cp36m-manylinux1_x86_64.whl (6.2MB)
100% |████████████████████████████████| 6.2MB 18kB/s
Requirement already satisfied: wheel>=0.26 in /home/hcq/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu==1.1.0)
Requirement already satisfied: six>=1.10.0 in /home/hcq/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu==1.1.0)
Requirement already satisfied: numpy>=1.11.0 in /home/hcq/anaconda3/lib/python3.6/site-packages (from tensorflow-gpu==1.1.0)
Requirement already satisfied: setuptools in /home/hcq/anaconda3/lib/python3.6/site-packages (from protobuf>=3.2.0->tensorflow-gpu==1.1.0)
Installing collected packages: protobuf, tensorflow-gp