0
我必須這樣做。在theano函數中返回np.array或np.matrix對象
import theano as th
import theano.tensor as T
x, y = T.dscalars('x', 'y')
z = np.matrix([[x*y, x-y], [x/y, x**2/(2*y)]])
f = th.function([x, y], z) # causes error
# next comes calculations like f(2, 1)*f(3, 2)*some_matrix
我知道最後一行不是有效的代碼,因爲th.function不支持返回這些對象。有沒有一種有效的方式來做到這一點,而不返回矩陣的所有元素並將其轉換爲np.matrix?