新聞中心
說明:系統(tǒng)是unbuntu14.04LTS,32位的操作系統(tǒng),以前安裝了python3.4,現(xiàn)在想要安裝theano和Keras。步驟如下:

我們提供的服務有:成都網(wǎng)站建設、成都網(wǎng)站設計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、牙克石ssl等。為上1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的牙克石網(wǎng)站制作公司
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時會出現(xiàn)以下錯誤:
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++編譯的話速度比較快,在網(wǎng)上找到的大部分解決方案都是基于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位系統(tǒng)上沒有對應的版本!用源文件安裝又很復雜)
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系統(tǒng)theano和keras的安裝方法,希望對大家有所幫助!
成都服務器托管選創(chuàng)新互聯(lián),先上架開通再付費。
創(chuàng)新互聯(lián)(www.cdcxhl.com)專業(yè)-網(wǎng)站建設,軟件開發(fā)老牌服務商!微信小程序開發(fā),APP開發(fā),網(wǎng)站制作,網(wǎng)站營銷推廣服務眾多企業(yè)。電話:028-86922220
網(wǎng)頁標題:ubuntu系統(tǒng)theano和keras的安裝方法
URL鏈接:http://www.fisionsoft.com.cn/article/cdepjgh.html


咨詢
建站咨詢
