Imagine we have a DoubleTensor - size: 5x32x3000
and we ant to convert it to DoubleTensor - size: 5x32x100
to feed in further. Now, what I would do is the following:
local seq = nn.Sequential()
seq:add(nn.SplitTable(1))
seq:add(nn.MapTable():add(nn.Linear(3000,100)))
seq:add(nn.JoinTable(1)):add(nn.View(5,32,100))
This looks a bit complicated, I feel like there should be a more efficient way. Can you come up with a better solution?
I have tried this, it will output size (5, 32, 1000) as you wanted
data = torch.Tensor(5, 32, 3000)
mul = torch.Tensor(3000, 1000)
res = torch.mm(data:view(5*32, 3000), mul):view(5, 32, 1000)
print(res:size())