从多个向量制作矩阵

用户名

是否可以从theano中的多个向量制作矩阵?

喜欢:

vector1, vector2, vector3 = theano.tensor.vector()
Matrix = [vector1, vector2, vector3]

类似于numpy操作:

Matrix = numpy.asarray([vector1, vector 2, vector3])
丹尼尔·伦肖

您可以使用theano.tensor.stack

这是一个工作示例:

import theano
import theano.tensor as tt

vector1, vector2, vector3 = tt.vectors(3)
matrix = tt.stack(vector1, vector2, vector3)
f = theano.function([vector1, vector2, vector3], matrix)
print f([1, 2, 3], [4, 5, 6], [7, 8, 9])

在哪里打印

[[ 1.  2.  3.]
 [ 4.  5.  6.]
 [ 7.  8.  9.]]

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章