windows64 CPU python2.7 安装theano & keras

时间:2025-04-26 07:17:49

根据这里 完成安装了theano包


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

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

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

4. 在这里 下载OpenBLAS 我下载了OpenBLAS-v0.2. 和 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,=-LC:/openblas -lopenblas

此时安装结束


运行:

import numpy as np
import time
import theano

print('=', )

A = (1000, 10000).astype()
B = (10000, 1000).astype()
np_start = ()
AB = (B)
np_end = ()
X, Y = ('XY')
mf = ([X, Y], (Y))
t_start = ()
tAB = mf(A, B)
t_end = ()
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" % ((AB - tAB).max(), ))

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

安装theano成功


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