If you use the default mode='nearest'.
Change it to mode='bilinear' and it should run:
x = torch.randn(1, 3, 24, 24)
up = nn.Upsample(size=47, mode='bilinear')
y = up(x)
print(y.shape)
> torch.Size([1, 3, 47, 47])