在torch中更新张量的某个切片。

如何在“Torch”中像在“Numpy”中使用m[begin:end, :]一样切片张量的行?

要运行的代码示例:

require 'torch'
m = torch.Tensor(10, 2):zero()
a = torch.Tensor(5, 2):fill(1)
m({{1,5}, {}}) = a -- Error at this line

期望的m

1  1
1  1
1  1
1  1
1  1
0  0
0  0
0  0
0  0
0  0
[torch.DoubleTensor of size 10x2]
点赞
用户1545917
用户1545917

我不得不使用方括号m[]代替圆括号。

其余的代码是正确的。

2015-10-20 22:36:55