我喜欢ndarray:
diag = []
diag.append(np.diag([1,1,0]))
diag.append(np.diag([0,1,1]))
diag
[array([[1, 0, 0],
[0, 1, 0],
[0, 0, 0]]), array([[0, 0, 0],
[0, 1, 0],
[0, 0, 1]])]
如何将其转换为float 64类型的Theano tensor变量,matrix?因为我需要像
那样执行点操作Theano.dot(diag, X) where X is shared variable of type float 64, matrix.
答案 0 :(得分:4)
只需像这样创建一个SharedVariable
diag_ = theano.shared(np.array(diag).astype("float64"))
theano.dot(diag_, X)
http://deeplearning.net/software/theano/library/compile/shared.html