在torch7 / lua
有一个矩阵:
[ 1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12;
13, 14, 15, 16 ]
如何提取这个:
[ 6, 7;
10, 11 ]
以及如何通过矩阵运算覆盖它
[ 1, 2, 3, 4;
5, 78, 66, 8;
9, 45, 21, 12;
13, 14, 15, 16 ]
提前致谢。
答案 0 :(得分:1)
matrix
matrix:sub(2,3,2,3)
z = torch.Tensor({{78,66},{45,21}})
matrix:sub(2,3,2,3):copy(z)