Lua 减去火炬张量中所有列的向量
给定一个维度为NxM的张量和一个向量Nx1,如何减去Torch中张量每列中的向量?一种可能性是使用。例如: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
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]
您能提供您已经尝试过的示例代码吗?请参阅以获取帮助,帮助您编写一个可以得到答案的问题