Upsampling trilinear for 3D data

I am trying to upsample 5D tensor using nn.Upsample:
size2=(16, 56,56)
self.interpolation1 = nn.Upsample(size=size2,mode=‘trilinear’)

and then using it in forward as:

         out_interp = self.interpolation1(out_middle_2r_blocks) + out_down_residual_blocks1

I get an error as:

                  return torch._C._nn.upsample_trilinear3d(input, _output_size(3), align_corners)
                   RuntimeError: Expected a list of 3 ints but got 2 for argument #2 'output_size'

Please help!

Your code seems to work for a 5-dimensional input:

x = torch.randn(1, 3, 4, 5, 6)
size2=(16, 56,56)
interpolation1 = nn.Upsample(size=size2,mode='trilinear', align_corners=False)
output = interpolation1(x)
1 Like