.dot 或其他 theano 函数的延迟评估

Lazy evaluation of .dot or other theano function

我是 python 和 theano 的新手,所以这个问题可能很愚蠢。

我在文档中读到 .dot 生成符号张量。我现在正在调试一些程序,没有任何容器或任何东西我都看不到 TensorVariable,而且我不知道如何从中获取值。

实际上不可能从符号变量中获取值,因为它们没有值;相反,它们代表稍后提供的值。

考虑以下示例:

x = theano.tensor.matrix()
y = theano.tensor.matrix()
z = theano.dot(x, y)
f = theano.function(inputs=[x, y], outputs=z)
a = numpy.array([[1,2,3],[4,5,6]])
b = numpy.array([[1,2],[3,4],[5,6]])
c = f(a, b)

这里,xy是符号矩阵。它们没有值,但它们代表将在编译和执行计算后提供的某些值。 abc 是具有值的具体矩阵。 f = theano.function(...) 行编译计算,c = f(...) 执行该函数,为 x 提供名为 a 的值,为 [=12] 提供名为 b 的值=]; return 值 c 接受由符号表达式 z.

计算的值