将 python ndarray 转换为 theano 张量类型变量

convert python ndarray to theano tensor type variable

我有像这样的 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, matrix 类型的 Theano 张量变量?因为我需要执行像

这样的点操作
Theano.dot(diag, X) where X is shared variable of type float 64, matrix.

像这样创建一个SharedVariable

diag_ = theano.shared(np.array(diag).astype("float64"))
theano.dot(diag_, X)

http://deeplearning.net/software/theano/library/compile/shared.html