我是theano的新手,当我尝试运行此代码时,我得到了以下回复:
1 import numpy
2 import theano
3 import theano.tensor as T
4 rng = numpy.random
5
6 N = 5
7 feats = 3
8 D = (rng.randn(N, feats), rng.randint(size=N, low=0, high=10))
9 training_steps = 10000
10
11 # Declare Theano symbolic variables
12 x = T.matrix("x")
13 y = T.vector("y")
14 w = theano.shared(rng.randn(feats), name="w")
15 b = theano.shared(0., name="b")
16 print "Initial model:"
17 # Construct Theano expression graph
18 print T.dot(x, w)
初始模型: dot.0
我怎样才能真正看到返回值的值,谢谢。
答案 0 :(得分:1)
您需要评估表达式,最好将其转换为函数。从代码中删除第18行,然后添加
dot_product = T.dot(x, w)
f = theano.function([x], dot_product)
print f(rng.randn(feats))