[401]import theano导入失败的解决方法

1、>>> import theano

WARNING (theano.configdefaults): g++not available, if using conda: conda install m2w64-toolchain WARNING (theano.configdefaults): g++not detected ! Theano will be unable to execute optimized C- imp

解决方法:

键入命令解决:conda install m2w64-toolchain

2、import theano 失败解决方法:

问题的解决方案就是安装libpython
查看conda list
如果没有libpython
然后输入一句命令:conda install libpython

然后,import theano,成功!

"""
python3.6
"""
import numpy as np
import theano.tensor as T
from theano import function
 
 
x = T.dscalar('x')
y = T.dscalar('y')
z = x+y     # define the actual function in here
f = function([x, y], z)  # the inputs are in [], and the output in the "z"
# def f(x,y):
#     return x+y
print(f(2,3))  # 输出2与3的和
 
# to pretty-print the function
from theano import pp 
print(pp(z))
 
# how about matrix
x = T.dmatrix('x')
y = T.dmatrix('y')
z = x + y # 矩阵积 z = T.dot(x,y)
f = function([x, y], z)
print(f(np.arange(12).reshape((3,4)), 10*np.ones((3,4))))

参考:https://blog.csdn.net/lucky_kai/article/details/70234026
https://www.cnblogs.com/luyaoblog/p/7224512.html

你可能感兴趣的:(异常)