我有 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
关于python - 将 python ndarray 转换为 theano 张量类型变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41198973/