人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

ubuntu系統(tǒng)theano和keras的安裝方法

發(fā)布日期:2022-02-14 17:25 | 文章來(lái)源:源碼之家

說明:系統(tǒng)是unbuntu14.04LTS,32位的操作系統(tǒng),以前安裝了python3.4,現(xiàn)在想要安裝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時(shí)會(huì)出現(xiàn)以下錯(cuò)誤:

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.
搜了一下是因?yàn)閠heano采用g++編譯的話速度比較快,在網(wǎng)上找到的大部分解決方案都是基于Anaconda安裝的,解決方法是:

conda install mingw libpython

3,安裝theano

sudo pip3 install theano

該命令會(huì)自動(dòng)下載theano所需要的依賴,包括numpy,scipy等等。

4,安裝keras

sudo pip3 install keras

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

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

5,測(cè)試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(), ))

總結(jié)

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

美國(guó)快速服務(wù)器

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對(duì)1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部