Change 1x1x33 tensor to 1x1x34

So let’s say for a smaller example I have the tensor that’s 1x2
[0,1]

I want to change it to
[0,1,0]
So append an extra column but leave everything else to same. Now I want to do this to a 3D tensor that is 1x1x33 to 1x1x34

torch.cat should do exactly this:

torch.cat((torch.randn(1, 1, 33), torch.randn(1, 1, 1)), dim=2)
import torch
import torch.nn.functional as F

x = torch.rand(1, 1, 33)
y = F.pad(x, (0, 1, 0, 0), mode='constant', value=0)
print(x.shape)
print(y.shape)

also works but is not recommended.