python - How can I apply a transformation to a torch tensor ...
stackoverflow.com › questions › 63756773Sep 05, 2020 · Since your input is spatial (based on the size=(28, 28)), you can fix that by adding the batch dimension and changing the mode, since linear is not implemented for spatial input: z = nnf.interpolate(z.unsqueeze(0), size=(28, 28), mode='bilinear', align_corners=False) If you want z to still have a shape like (C, H, W), then:
Upsample — PyTorch 1.10.1 documentation
pytorch.org › docs › stableUpsample. Upsamples a given multi-channel 1D (temporal), 2D (spatial) or 3D (volumetric) data. The input data is assumed to be of the form minibatch x channels x [optional depth] x [optional height] x width . Hence, for spatial inputs, we expect a 4D Tensor and for volumetric inputs, we expect a 5D Tensor.
How can I apply a transformation to a torch tensor
https://stackoverflow.com/questions/63756773/how-can-i-apply-a...05.09.2020 · Since your input is spatial (based on the size=(28, 28)), you can fix that by adding the batch dimension and changing the mode, since linear is not implemented for spatial input: z = nnf.interpolate(z.unsqueeze(0), size=(28, 28), mode='bilinear', align_corners=False) If you want z to still have a shape like (C, H, W), then: