import theano 匯入失敗的解決方法
阿新 • • 發佈:2018-12-10
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))))