windows64 CPU python2.7 安装theano & keras

来源:互联网 发布:淘宝网店订单处理 编辑:程序博客网 时间:2024/05/29 08:33

根据这里 完成安装了theano包


1. 从gitbub上下载并解压theano  地址

2. 在cmd中, 执行"conda install mingw libpython". 这将安装mingw g++ 和libpython (前提安装了Anaconda)

3. 在cmd中, 进入解压后的theano目录中执行"python setup.py install --record files.txt"

4. 在这里 下载OpenBLAS 我下载了OpenBLAS-v0.2.14-Win64-int64.zip 和 mingw64_dll.zip (电脑64位)

5. 创建C:\openblas文件夹, 将上述两个压缩包解压, 将mingw64_dll中的所有dll文件和OpenBLAS-v0.2.14-Win64-int64/bin中的dll文件放入C:\openblas中

6. 在环境变量path中添加C:\openblas

7. 创建一个新的环境变量 名为THEANO_FLAGS  值为device=cpu,blas.ldflags=-LC:/openblas -lopenblas

此时安装结束


运行:

import numpy as npimport timeimport theanoprint('blas.ldflags=', theano.config.blas.ldflags)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(), ))

输出 NP time: 0.454026[s], theano time: 0.553031[s]

安装theano成功


安装keras: 在cmd中输入pip install keras 即可

0 0