MacOSX 安裝 TensorFlow

TensorFlow是一個端到端開源機器學習平臺。它擁有一個包含各類工具、庫和社區資源的全面靈活生態系統,能夠讓研究人員推進機器學習領域的先進技術的。

準備

安裝 Anaconda

TensorFlow 安裝的前提是系統安裝了 Python 2.5 或更高版本,教程中的例子是以 Python 3.6(Anaconda 3 版)爲基礎設計的。爲了安裝 TensorFlow,首先確保你已經安裝了 Anaconda。能夠從網址(https://www.anaconda.com/dist...)中下載並安裝適用於 Windows/macOS 或 Linux 的 Anaconda。python

這個是 macos的鏈接,一個是命令行的,一個是GUI的

https://repo.anaconda.com/arc...程序員

https://repo.anaconda.com/arc...macos

關於安裝 anaconda, 能夠參考官方的文檔。segmentfault

https://docs.anaconda.com/ana...

配置 Anaconda

執行這個命令source ~/.bash_profile, 其實查看這個文件.bash_profile,關鍵的信息export PATH="/opt/anaconda3/bin:$PATH",就是配置anaconda的環境變量。
而後執行conda -Vapi

(base) ➜ OpenSource conda -V
conda 4.7.12

安裝

配置 pip 源

這一步能夠省略,可是配置爲國內的源以後,速度快的飛起來。
sudo vi /Users/username/Library/Application\ Support/pip/pip.conf,而後修改裏面的內容爲下面的源。bash

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

保存退出便可。機器學習

安裝

當前版本只支持 CPU工具

pip install https://storage.googleapis.co...\
或者乾脆直接用 pip install tensorflow同樣的。

Hello TensorFlow

這是第一個程序學習

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

# Hello, TensorFlow!
若是你感興趣能夠關注公衆號「chasays」- 程序員匯聚地
在這裏插入圖片描述
相關文章
相關標籤/搜索