win 安装 theano 和 keras的步骤 anaconda2
gpu配置参考 http://blog.csdn.net/niuwei22007/article/details/47684673
http://blog.csdn.net/m624197265/article/details/45700619
友情提示:安装的时候关掉360
1. 下载anconda-python对应的win 64位版本并安装
2. 将C:\Anaconda2和C:\Anaconda2\Scripts加入path环境变量
如果觉得和系统python有冲突,那么复制C:\Anaconda2\python.exe 》》C:\Anaconda2\pythona.exe 即可
以后可以用pythona进行访问
3. 此步骤可能需要翻墙
执行命令安装libpython,否则theano可能无法import
conda install libpython
注意:执行命令 conda search --json mingw 可以找到包的下载地址,这样可以用迅雷下载
4. 添加环境变量进入path
C:\Anaconda2\MinGW\bin
C:\Anaconda2\MinGW\x86_64-w64-mingw32\lib
5. conda install theano 或者官网下包,然后解压用pythona setup.py install安装也行
6. 在主文件夹里添加配置文件
我这里是C:\Users\Administrator新建.theanorc.txt,格式为用notepad++打开--转为【utf8-无bom】---很重要,不然会爆第7条的错误
##################################
[global]
openmp=False
[blas]
ldflags=
[gcc]
cxxflags = -IC:\Anaconda2\MinGW\x86_64-w64-mingw32\include
cxxflags = -LC:\Anaconda2
#################################
然后重启电脑即可进入python环境--很重要,必须重启电脑
pythona
>>> import theano
>>>
就不会报错了,这里可能需要等待几十秒钟
7.如果运行报unicode错误
则是因为
C:\Anaconda2\Lib\site-packages\Theano-0.9.0.dev0-py2.7.egg\theano\gof\cmodule.py
420行下面改为
_to_hash=[]
for i in to_hash:
if type(i)!=str:
print(i,type(i))
_to_hash.append(i.encode('utf-8'))
else:
_to_hash.append(i)
return hash_from_code('\n'.join(_to_hash))
重要命令: python -c "import theano; print(theano.config)" | less #win7用双引号
例子参考http://blog.csdn.net/u012162613/article/details/45397033 一个实例
http://www.jianshu.com/p/b8a703df5318 win64---的配置
http://keras.io/getting-started/faq/#how-can-i-run-keras-on-gpu 官方文档,用gpu,保存model
http://blog.csdn.net/garfielder007/article/details/50580900 实例
http://blog.csdn.net/niuwei22007/article/details/49229909 实例 callback
http://www.bubuko.com/infodetail-1066303.html 实例 图表
# plot the result
plt.figure
plt.plot(result.epoch,result.history[‘acc‘],label="acc")
plt.plot(result.epoch,result.history[‘val_acc‘],label="val_acc")
plt.scatter(result.epoch,result.history[‘acc‘],marker=‘*‘)
plt.scatter(result.epoch,result.history[‘val_acc‘])
plt.legend(loc=‘under right‘)
plt.show()
plt.figure
plt.plot(result.epoch,result.history[‘loss‘],label="loss")
plt.plot(result.epoch,result.history[‘val_loss‘],label="val_loss")
plt.scatter(result.epoch,result.history[‘loss‘],marker=‘*‘)
plt.scatter(result.epoch,result.history[‘val_loss‘],marker=‘*‘)
plt.legend(loc=‘upper right‘)
plt.show()