Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua 减去火炬张量中所有列的向量_Lua_Torch - Fatal编程技术网

Lua 减去火炬张量中所有列的向量

Lua 减去火炬张量中所有列的向量,lua,torch,Lua,Torch,给定一个维度为NxM的张量和一个向量Nx1,如何减去Torch中张量每列中的向量?一种可能性是使用。例如: local A = torch.Tensor{{1, 2},{3, 4},{5,6}} local B = torch.ones(3) local C = A - B:view(3, 1):expandAs(A) -- make a 3x1 tensor before expand print(C) -- 0 1 -- 2 3 -- 4 5 -- [torch.DoubleTe

给定一个维度为NxM的张量和一个向量Nx1,如何减去Torch中张量每列中的向量?

一种可能性是使用。例如:

local A = torch.Tensor{{1, 2},{3, 4},{5,6}}
local B = torch.ones(3)
local C = A - B:view(3, 1):expandAs(A) -- make a 3x1 tensor before expand
print(C)
--  0  1
--  2  3
--  4  5
-- [torch.DoubleTensor of size 3x2]

您能提供您已经尝试过的示例代码吗?请参阅以获取帮助,帮助您编写一个可以得到答案的问题