Sublime Text3搭建Tensorflow环境

作者: TTM_Ronald | 来源:发表于2018-02-08 22:37 被阅读0次

最近在Mac上练习一些Tensorflow简单代码,搭建了Sublime Text3的Tensorflow环境,Ubuntu环境下搭建步骤类似

  • 电脑:Mac
  • 软件:Sublime Text3

1. 安装Sublime Text3

a. 从Sublime Text3官网下载Sublime Text3 for Mac 3153版本安装包安装
b. 根据安装提示输入以下License信息

----- BEGIN LICENSE -----
TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB
------ END LICENSE ------

2. 配置Sublime Text3

  • 配置信息设置路径:
Sublime Text -> Preferences -> Settings

a. Settings Default:默认设置不做修改
b. Settings User:用户设置编写修改


  • 配置样例说明

a. 关闭Sublime Text3自动搜索提示更新版本
b. 设置界面风格

{
    //关闭版本更新提示
    "ignored_packages":
    [
    "Vintage"
    ],
    "update_check": false,
    //设置界面风格
    "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
    "dictionary": "Packages/Language - English/en_GB.dic",
    "expand_tabs_on_save": true,
    "fold_buttons": true,
    "font_size": 14,
    "bold_folder_labels": true, 
    "word_wrap":true,
    "wrap_width":80, 
    "rulers":[80,100], 
    "vintage_ctrl_keys": true, 
    "vintage_start_in_command_mode": true, 
    "line_padding_bottom": 2, 
    "line_padding_top": 2, 
    "tab_size": 4, 
    "theme": "Default.sublime-theme", 
    "translate_tabs_to_spaces": true, 
    "font_face": "YaHei Consolas Hybrid",
    "caret_style": "phase",
    "highlight_line": true,
    "highlight_modified_tabs": true,
}

3. 安装Sublime Text3插件

  • 安装 Package Control

a. 打开Console命令行两种方式:

Ctrl+`快捷键/Sublime Text -> View -> Show Console

b. 粘贴并回车运行如下代码:

import urllib.request,os; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), ‘wb‘).write(urllib.request.urlopen( ‘http://sublime.wbond.net/‘ + pf.replace(‘ ‘,‘%20‘)).read())

c. Package Control安装成功说明:

Sublime Text -> Preferences下出现Package Control选项
  • 安装所需插件

a. 打开Package Control

Sublime Text -> Preferences -> Package Control

b. 选择安装组件

Package Control: Install Package

c. 可选择安装所需插件


d. 设置Sublime Text3主题
Nexus


Soda Dark

4. 终端Terminal配置Tensorflow环境

  • Python2配置Tensorflow环境
sudo apt-get update
//安装Python2
sudo apt-get install python
//安装pip
sudo apt-get install python-pip
//安装numpy
sudo pip install numpy
//安装matplotlib
sudo pip install matplotlib
//安装scipy
sudo pip install scipy
//安装pandas
sudo pip install pandas
//安装深度学习框架keras
sudo pip install keras
//安装深度学习框架tensorflow(CPU)
sudo pip install tensorflow
  • Python3配置Tensorflow环境
sudo apt-get update
//安装Python3
sudo apt-get install python3
//安装pip3
sudo apt-get install python3-pip
//安装numpy
sudo pip3 install numpy
//安装matplotlib
sudo pip3 install matplotlib
//安装scipy
sudo pip3 install scipy
//安装pandas
sudo pip3 install pandas
//安装深度学习框架keras
sudo pip3 install keras
//安装深度学习框架tensorflow(CPU)
sudo pip3 install tensorflow

5. Sublime Text3配置Python3编译接口

a. 打开编译接口设置路径

Tools -> Build System -> New Build System

b. 填写Python3编译接口配置程序

{ 
    “cmd”: [“/python/to/path”, “-u”, “$file”], 
    “file_regex”: “^[ ]File \”(…?)\”, line ([0-9]*)”, 
    “selector”: “source.python” 
}
  • 接口程序说明
“/python/to/path”:电脑上Python3的安装路径
  • 终端Terminal查看Python3安装路径命令
which python3

c. 保存接口程序在默认路径
d. 设置Python3编译环境

Tools -> Build System -> Python3

6. Sublime Text3训练MNIST数据集

a. 终端Terminal下载Keras包

git clone https://github.com/fchollet/keras.git

b. Sublime Text3打开样例程序

样例程序路径:keras -> examples -> mnist_mlp.py

c. 程序运行快捷键说明

Command+B

d. MNIST数据集训练结果


  • Test loss:0.1068
  • Test accuracy:0.9829

相关文章

网友评论

    本文标题:Sublime Text3搭建Tensorflow环境

    本文链接:https://www.haomeiwen.com/subject/fsdxtftx.html