How to pass a 3D tensor to Linear layer?
I have a 3D tensor (5x9x12) I want to cast it to a (5x9x1) tensor through the linear layer. But I found that the nn.LinearLayer require that the input should be a matrix instead of a 3d tensor. How can I achieve my task?
maplewizard
You can do that with Tensor.view() <SCODE>x = x.view(-1, 12)
b_size = x.size(0)
x = linear(x)
x = x.view(b_size, -1, 1)<ECODE>
kim.seonghyeon
Thanks, it is likely to solve my problem. If there is a single function to to the trick, it would be more clear.
maplewizard
unnatjain
Could you explain how to do this in a non iterative manner? I think it would be very helpful
Dimitrisl
mattheus_lee