如题所述
1. é¦å
å®è£
pythonï¼æéæ©å®è£
Anaconda ï¼Windows 64-Bit Python 2.7 Graphical Installer ä¸è½½å°åï¼ã
Anacondaçä¸äºå½ä»¤ï¼å¨Anacondaçå½ä»¤è¡çªå£è¾å ¥ï¼ï¼
conda list #该å½ä»¤ï¼å°ååºAnacondaå®è£ çææåºç¨å ï¼æ们å¯ä»¥çå°Anacondaå·²ç»å®è£ äºnumpy, nose, pip, python, scipy, mingwççã
conda install <pkg name> #该å½ä»¤ç¨äºå®è£ åºç¨å ï¼å¦ conda install numpy.
pip install <pkg name> #该å½ä»¤ç¨äºå®è£ åºç¨å ï¼å¦ pip install theano.
conda update <pkg name> #å级åºç¨å ï¼å¦ conda update python
2. å®è£ Theanoï¼å¨Anaconda çå½ä»¤çªå£ä¸è¾å ¥ pip install theanoï¼å¯ä»¥çå°ç¨åºå¼å§ä¸è½½å®è£ å ï¼å¹¶æ£æ¥æ¯å¦æ»¡è¶³å®è£ æ¡ä»¶ï¼numpy>=1.5.0ï¼scipy>=0.7.2ï¼æ»¡è¶³æ¡ä»¶ä¹åå¼å§è¿è¡setup.pyå®è£ theanoï¼å®è£ å®æåä¼æ¾ç¤ºSuccessfully installed theanoã
3. æµè¯Theanoå®è£ æ åµã
ï¼1ï¼å¨ipythonä¸è¾å ¥ä»¥ä¸ä¸¤è¡ä»£ç ï¼
import theano
theano.test()
ä¼æ¾ç¤ºtheanoççæ¬å·ï¼å®è£ ä½ç½®ï¼å·²ç»å ¶ä»å çå®è£ çæ¬ï¼å¦numpy,nose,pythonçã
å¨è¿è¡ä¸åºç°g++ä¸æ¯å é¨æå¤é¨å½ä»¤ï¼ä¹ä¸æ¯å¯è¿è¡çç¨åºææ¹å¤çæ件ã
ï¼2ï¼å¨Anacondaçå½ä»¤è¡çªå£è¾å ¥ï¼python Lib\site-packages\theano\tests\run_tests_in_batch.py
æ¾ç¤ºunable to find theano-noseï¼æ¥çrun_tests_in_batch.pyåç°ï¼å ¶ä¸è·¯å¾è®¾ç½®ä¸ºå¨binä¸å¯»æ¾theano-noseæ件ï¼èå®é ä¸Anacondaæ件夹ä¸æ ¹æ¬æ²¡æbinè¿ä¸ªæ件夹ï¼theano-noseåæ¾å¨Scriptsæ件夹ä¸ã
ãããå°è¯1ï¼å°Scriptsæ´å为binï¼éæ°è¿è¡è¿å¥å½ä»¤ï¼å¯ä»¥æåè¿è¡ãä½æ¯åºç°ä¸ä¸ªwarningï¼æ示没ææ£æµå°g++ï¼æ以æ æ³è¿è¡ä¼ååçC代ç çæ¬ï¼åªè½æ§è¡pythonçæ¬ã
该ç§å°è¯çç»ææ¯ï¼ä¸æ¬¡æå¼Anaconda å½ä»¤çªå£ååºç°é误ï¼å ä¸ºå ¶è¿è¡è·¯å¾ä¸ºScriptsï¼æ以è¿æ¯ä¸è¦ä¿®æ¹äºã
ï¼3ï¼g++é®é¢ãæ们æå¼MinGWæ件夹ï¼å¯ä»¥å¾æ¸ æ¥ççå°æg++ï¼ä½æ¯ä¸ºä»ä¹ä½¿ç¨ä¸äºå¢ï¼ï¼å¨Anaconda å½ä»¤çªå£ä¸è¾å ¥g++ä¹è½æåè°ç¨g++.exeåãæ以ç»è®ºæ¯ï¼é´äºè¿ä¸ªä»£ç ä¸åºç°å¾ææ¾çæ¼æ´ï¼æ以说ä¸å®è¿éä¹æ¯é误ï¼å ä¸ç®¡è¿äºäºã
è¯çåäºä»¥ä¸é ç½®ï¼ä¹ä¸ç¥è¡ä¸è¡ã
æ·»å ç¯å¢åé: path: C:\Anaconda\MinGW\bin;C:\Anaconda\MinGW\x86_64-w64-mingw32\lib;
æ°å»ºç¯å¢åéï¼ PYTHONPATH: C:\Anaconda\Lib\site-packages\theano;
å¨homeç®å½ä¸ï¼cmdå¯ä»¥çå°ï¼æçæ¯C:\Users\Administratorï¼ï¼å建 .theanorc.txt æ件å 容å¦ä¸ï¼
[global]
openmp=False
[blas]
ldflags=
[gcc]
cxxflags = -IC:\MinGW\include
ï¼4ï¼éªè¯BLASæ¯å¦å®è£ æåãç±äºnumpyæ¯ä¾èµBLASçï¼å¦æBLAS没æå®è£ æåï¼è½ç¶numpy亦å¯ä»¥å®è£ ï¼ä½æ¯æ æ³ä½¿ç¨BLASçå éãéªè¯numpyæ¯å¦ççæåä¾èµBLASç¼è¯ï¼ç¨ä»¥ä¸ä»£ç è¯éªï¼
>>> import numpy
>>> id(numpy.dot) == id(numpy.core.multiarray.dot)
False
ç»æ为False表示æåä¾èµäºBLASå éï¼å¦ææ¯Tureå表示ç¨çæ¯pythonèªå·±çå®ç°å¹¶æ²¡æå éã
Anacondaçä¸äºå½ä»¤ï¼å¨Anacondaçå½ä»¤è¡çªå£è¾å ¥ï¼ï¼
conda list #该å½ä»¤ï¼å°ååºAnacondaå®è£ çææåºç¨å ï¼æ们å¯ä»¥çå°Anacondaå·²ç»å®è£ äºnumpy, nose, pip, python, scipy, mingwççã
conda install <pkg name> #该å½ä»¤ç¨äºå®è£ åºç¨å ï¼å¦ conda install numpy.
pip install <pkg name> #该å½ä»¤ç¨äºå®è£ åºç¨å ï¼å¦ pip install theano.
conda update <pkg name> #å级åºç¨å ï¼å¦ conda update python
2. å®è£ Theanoï¼å¨Anaconda çå½ä»¤çªå£ä¸è¾å ¥ pip install theanoï¼å¯ä»¥çå°ç¨åºå¼å§ä¸è½½å®è£ å ï¼å¹¶æ£æ¥æ¯å¦æ»¡è¶³å®è£ æ¡ä»¶ï¼numpy>=1.5.0ï¼scipy>=0.7.2ï¼æ»¡è¶³æ¡ä»¶ä¹åå¼å§è¿è¡setup.pyå®è£ theanoï¼å®è£ å®æåä¼æ¾ç¤ºSuccessfully installed theanoã
3. æµè¯Theanoå®è£ æ åµã
ï¼1ï¼å¨ipythonä¸è¾å ¥ä»¥ä¸ä¸¤è¡ä»£ç ï¼
import theano
theano.test()
ä¼æ¾ç¤ºtheanoççæ¬å·ï¼å®è£ ä½ç½®ï¼å·²ç»å ¶ä»å çå®è£ çæ¬ï¼å¦numpy,nose,pythonçã
å¨è¿è¡ä¸åºç°g++ä¸æ¯å é¨æå¤é¨å½ä»¤ï¼ä¹ä¸æ¯å¯è¿è¡çç¨åºææ¹å¤çæ件ã
ï¼2ï¼å¨Anacondaçå½ä»¤è¡çªå£è¾å ¥ï¼python Lib\site-packages\theano\tests\run_tests_in_batch.py
æ¾ç¤ºunable to find theano-noseï¼æ¥çrun_tests_in_batch.pyåç°ï¼å ¶ä¸è·¯å¾è®¾ç½®ä¸ºå¨binä¸å¯»æ¾theano-noseæ件ï¼èå®é ä¸Anacondaæ件夹ä¸æ ¹æ¬æ²¡æbinè¿ä¸ªæ件夹ï¼theano-noseåæ¾å¨Scriptsæ件夹ä¸ã
ãããå°è¯1ï¼å°Scriptsæ´å为binï¼éæ°è¿è¡è¿å¥å½ä»¤ï¼å¯ä»¥æåè¿è¡ãä½æ¯åºç°ä¸ä¸ªwarningï¼æ示没ææ£æµå°g++ï¼æ以æ æ³è¿è¡ä¼ååçC代ç çæ¬ï¼åªè½æ§è¡pythonçæ¬ã
该ç§å°è¯çç»ææ¯ï¼ä¸æ¬¡æå¼Anaconda å½ä»¤çªå£ååºç°é误ï¼å ä¸ºå ¶è¿è¡è·¯å¾ä¸ºScriptsï¼æ以è¿æ¯ä¸è¦ä¿®æ¹äºã
ï¼3ï¼g++é®é¢ãæ们æå¼MinGWæ件夹ï¼å¯ä»¥å¾æ¸ æ¥ççå°æg++ï¼ä½æ¯ä¸ºä»ä¹ä½¿ç¨ä¸äºå¢ï¼ï¼å¨Anaconda å½ä»¤çªå£ä¸è¾å ¥g++ä¹è½æåè°ç¨g++.exeåãæ以ç»è®ºæ¯ï¼é´äºè¿ä¸ªä»£ç ä¸åºç°å¾ææ¾çæ¼æ´ï¼æ以说ä¸å®è¿éä¹æ¯é误ï¼å ä¸ç®¡è¿äºäºã
è¯çåäºä»¥ä¸é ç½®ï¼ä¹ä¸ç¥è¡ä¸è¡ã
æ·»å ç¯å¢åé: path: C:\Anaconda\MinGW\bin;C:\Anaconda\MinGW\x86_64-w64-mingw32\lib;
æ°å»ºç¯å¢åéï¼ PYTHONPATH: C:\Anaconda\Lib\site-packages\theano;
å¨homeç®å½ä¸ï¼cmdå¯ä»¥çå°ï¼æçæ¯C:\Users\Administratorï¼ï¼å建 .theanorc.txt æ件å 容å¦ä¸ï¼
[global]
openmp=False
[blas]
ldflags=
[gcc]
cxxflags = -IC:\MinGW\include
ï¼4ï¼éªè¯BLASæ¯å¦å®è£ æåãç±äºnumpyæ¯ä¾èµBLASçï¼å¦æBLAS没æå®è£ æåï¼è½ç¶numpy亦å¯ä»¥å®è£ ï¼ä½æ¯æ æ³ä½¿ç¨BLASçå éãéªè¯numpyæ¯å¦ççæåä¾èµBLASç¼è¯ï¼ç¨ä»¥ä¸ä»£ç è¯éªï¼
>>> import numpy
>>> id(numpy.dot) == id(numpy.core.multiarray.dot)
False
ç»æ为False表示æåä¾èµäºBLASå éï¼å¦ææ¯Tureå表示ç¨çæ¯pythonèªå·±çå®ç°å¹¶æ²¡æå éã
温馨提示:答案为网友推荐,仅供参考