校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > ubuntu系統theano和keras的安裝方法

ubuntu系統theano和keras的安裝方法

熱門標簽:百度地圖標注尺寸無法顯示 代理外呼系統創業 長春電銷外呼系統代理商 泰州智能外呼系統排名 大連電銷外呼系統運營商 外呼系統虛擬號碼 接電話機器人罵人 400電話干嘛怎么申請信用卡 400電話申請知乎

說明:系統是unbuntu14.04LTS,32位的操作系統,以前安裝了python3.4,現在想要安裝theano和keras。步驟如下:

1,安裝pip

sudo apt-get install python3-setuptools
sudo easy_install3 pip

2,安裝g++

 sudo apt-get install g++

采用上述命令安裝g++,安裝完成后可用g++ -version查看是否安裝完成。注意,如果沒有安裝g++,在import theano時會出現以下錯誤:

WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
搜了一下是因為theano采用g++編譯的話速度比較快,在網上找到的大部分解決方案都是基于Anaconda安裝的,解決方法是:

conda install mingw libpython

3,安裝theano

sudo pip3 install theano

 該命令會自動下載theano所需要的依賴,包括numpy,scipy等等。

4,安裝keras

sudo pip3 install keras

 最后需要注意的是,keras默認的backend是tensorflow,我們需要的是theano,所以需要修改下設置。(而且tensorflow用pip3安裝,在32位系統上沒有對應的版本!用源文件安裝又很復雜)

vim ~/.keras/keras.json
{
 
  "image_dim_ordering":"tf",
 
  "epsilon":1e-07,
 
  "floatx":"float32",
 
  "backend":"theano"
}

 5,測試theano

import numpy as np 
import time 
import theano 
A = np.random.rand(1000,10000).astype(theano.config.floatX) 
B = np.random.rand(10000,1000).astype(theano.config.floatX) 
np_start = time.time() 
AB = A.dot(B) 
np_end = time.time() 
X,Y = theano.tensor.matrices('XY') 
mf = theano.function([X,Y],X.dot(Y)) 
t_start = time.time() 
tAB = mf(A,B) 
t_end = time.time() 
print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" %( 
                      np_end-np_start, t_end-t_start)) 
print("Result difference: %f" % (np.abs(AB-tAB).max(), ))

總結

以上所述是小編給大家介紹的ubuntu系統theano和keras的安裝方法,希望對大家有所幫助!

標簽:臺灣 安陽 雅安 大慶 清遠 中衛 長治 興安盟

巨人網絡通訊聲明:本文標題《ubuntu系統theano和keras的安裝方法》,本文關鍵詞  ubuntu,系統,theano,和,keras,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ubuntu系統theano和keras的安裝方法》相關的同類信息!
  • 本頁收集關于ubuntu系統theano和keras的安裝方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 张北县| 江津市| 那曲县| 西安市| 黄石市| 双江| 两当县| 鄱阳县| 旬阳县| 酉阳| 临夏市| 喀喇沁旗| 安顺市| 杭锦后旗| 疏附县| 连山| 垫江县| 新津县| 黄陵县| 綦江县| 堆龙德庆县| 台安县| 扶沟县| 东城区| 都安| 潜江市| 皮山县| 孝昌县| 西贡区| 育儿| 新安县| 奉节县| 凤冈县| 四平市| 桑植县| 穆棱市| 怀安县| 定南县| 遵义县| 徐汇区| 竹溪县|