I have a tensor of shape [2, 2] where the first 2 is the batch size

I want to make this tensor to [2, 64] at the forward function. (Repeat 32 times)

How can I do it? the torch’s repeat api changes every dimension… (for e.g : [64, 64] comes out)

I have a tensor of shape [2, 2] where the first 2 is the batch size

I want to make this tensor to [2, 64] at the forward function. (Repeat 32 times)

How can I do it? the torch’s repeat api changes every dimension… (for e.g : [64, 64] comes out)

`torch.repeat()`

lets us specify the number of times to repeat for each dimension.

Something like below should work:

```
>>> import torch
>>> x = torch.randn(2,2)
>>> y = x.repeat(1, 32)
>>> y.shape
torch.Size([2, 64])
```

1 Like