ubuntu系統(tǒng)theano和keras的安裝方法
說(shuō)明:系統(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查看是否安裝完成。注意,如果沒(méi)有安裝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所需要的依賴(lài),包括numpy,scipy等等。
4,安裝keras
sudo pip3 install keras
最后需要注意的是,keras默認(rèn)的backend是tensorflow,我們需要的是theano,所以需要修改下設(shè)置。(而且tensorflow用pip3安裝,在32位系統(tǒng)上沒(méi)有對(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ì)大家有所幫助!
欄 目:Linux/apache
本文標(biāo)題:ubuntu系統(tǒng)theano和keras的安裝方法
本文地址:http://mengdiqiu.com.cn/a1/Linux_apache/10572.html
您可能感興趣的文章
- 01-10Linux被中斷的系統(tǒng)如何調(diào)用詳解
- 01-10Linux系統(tǒng)文件的默認(rèn)權(quán)限和特殊權(quán)限
- 01-10ubuntu19.04安裝教程(圖文步驟)
- 01-10windows 用VMware創(chuàng)建linux虛擬機(jī)安裝CentOS7.2操作系統(tǒng)
- 01-10Windows操作系統(tǒng)下Linux虛擬機(jī)的安裝與配置教程圖解
- 01-10通過(guò) SSH 在遠(yuǎn)程 Linux 系統(tǒng)上運(yùn)行命令的方法
- 01-10CentOS7系統(tǒng)增加swap的操作方法實(shí)例
- 01-10Ubuntu18.04 一鍵升級(jí)Python所有第三方包 及安裝python包的方法
- 01-10Ubuntu E: 無(wú)法獲得鎖 /var/lib/dpkg/lock-frontend - open (11: 資源暫時(shí)
- 01-10詳解Ubuntu16.04安裝nvidia驅(qū)動(dòng)+CUDA+cuDNN的教程


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 04-02linux關(guān)閉串口命令 關(guān)閉linux端口命令
- 04-02linux文件命令重命名 linux重命名文件名
- 04-02linux中jobs命令 shell jobs命令
- 04-02linux命令注入過(guò)濾 linux 代碼注入
- 04-02linux依次執(zhí)行命令 linux命令的執(zhí)行過(guò)程
- 04-02linux命令注銷(xiāo)vnc linux命令行注銷(xiāo)用戶(hù)
- 04-02linux命令免輸入 linux配置免密登錄
- 04-02軟交換linux命令 軟交換網(wǎng)絡(luò)主要協(xié)議
- 04-02linux命令歷史記錄 linux查看歷史記錄的
- 04-02linux命令頁(yè)面 linux命令頁(yè)面中文
隨機(jī)閱讀
- 01-10delphi制作wav文件的方法
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 01-10C#中split用法實(shí)例總結(jié)
- 04-02jquery與jsp,用jquery
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改