Given a tensor of dimensions NxM and a vector Nx1, how do I subtract the vector in each column of the tensor in Torch?
One possibility is to use expand. Example:
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]