久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ubuntu如何安裝theano和keras

191次閱讀
沒有評論

共計 1623 個字符,預(yù)計需要花費 5 分鐘才能閱讀完成。

這篇文章主要介紹“ubuntu 如何安裝 theano 和 keras”,在日常操作中,相信很多人在 ubuntu 如何安裝 theano 和 keras 問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”ubuntu 如何安裝 theano 和 keras”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學(xué)習(xí)吧!

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 默認(rèn)的 backend 是 tensorflow,我們需要的是 theano,所以需要修改下設(shè)置。(而且 tensorflow 用 pip3 安裝,在 32 位系統(tǒng)上沒有對應(yīng)的版本!用源文件安裝又很復(fù)雜)

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(), ))

到此,關(guān)于“ubuntu 如何安裝 theano 和 keras”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-14發(fā)表,共計1623字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 通辽市| 独山县| 内黄县| 东乌珠穆沁旗| 临猗县| 东平县| 霞浦县| 长乐市| 三河市| 卓尼县| 西宁市| 惠东县| 铜陵市| 广平县| 延长县| 日土县| 三都| 长泰县| 新巴尔虎左旗| 富民县| 江安县| 上栗县| 明光市| 长治县| 遂溪县| 清丰县| 鞍山市| 洱源县| 陕西省| 乐平市| 宝鸡市| 东丰县| 潜江市| 扎赉特旗| 遵义市| 芜湖市| 东乡县| 大冶市| 和静县| 留坝县| 嘉峪关市|