Looking for a pytorch function to repeat a vector

Viewed 368

I am looking for a pytorch function that is similar to tf's tile function. I saw that PyTorch used to have a tile function, but apparently it was removed.

An example for the functionality I am looking for: Let's say I have a tensor of dimensions (1,1,1,1000), I want to repeat it several times so I get a (1,40,40,1000) tensor.

1 Answers

Torch tensors have a repeat() method, therefore:

a = torch.rand((1, 1, 1, 1000))
b = a.repeat(1, 40, 40, 1)
b.shape  # Gives torch.Size([1, 40, 40, 1000])
Related