Hi,
x=torch.zeros((3,112,112),dtype=torch.float32)
x.size() #torch.Size([3, 112, 112])
I want to repeat and stack this tensor 25 times as a tensor with shape torch.Size([25, 3, 112, 112])
what are some neat ways to do it?
Thanks.
If I am not mistaken you need the repeat function ? Here is an example:
a = torch.tensor([
[1., 2.]
[3., 4.]
])
b = a.repeat([2, 1, 1]) # repeat twice
print(b)
tensor([[[1., 2.],
[3., 4.]],
[[1., 2.],
[3., 4.]]])
Thanks, I will try it. looks like the api I am looking for.