 5

# Got 3D input, but trilinear mode needs 5D input

Package: torch 50580
Exception Class:
NotImplementedError

## Raise code

``````    if input.dim() == 4 and mode == "bicubic":
assert align_corners is not None

if input.dim() == 3 and mode == "bilinear":
raise NotImplementedError("Got 3D input, but bilinear mode needs 4D input")
if input.dim() == 3 and mode == "trilinear":
raise NotImplementedError("Got 3D input, but trilinear mode needs 5D input")
if input.dim() == 4 and mode == "linear":
raise NotImplementedError("Got 4D input, but linear mode needs 3D input")
if input.dim() == 4 and mode == "trilinear":
raise NotImplementedError("Got 4D input, but trilinear mode needs 5D input")
if input.dim() == 5 and mode == "linear":
raise NotImplementedError("Got 5D input, but linear mode needs 3D input")
if input.dim() == 5 and mode == "bilinear":``````
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

## Ways to fix 5 When the torch.nn.Upsample initialized in 'trilinear' mode a 5D input is expected.

Step to reproduce the error:

```import torch

input_3x3 = torch.zeros(3, 3).view(1,3, 3) #Here a 3D tensor is provided
m = torch.nn.Upsample(scale_factor=2, mode='trilinear')
m(input_3x3)
```

Fixed version of the code

The tensor should be reshaped to a 5D.

```from torch import nn
# here the input is reshaped to 5D tensor. this fixes the error
input_5x5 = torch.zeros(3, 3).view(1,1, 1, 3, 3)
m = nn.Upsample(scale_factor=2, mode='trilinear')
m(input_5x5)
```