I have a tensor sized (1, 160) I need to resize it to (20, 20, and divide each of the 4 corresponding (20, 20) tensors by a different number, and then resize the tensor and return it as (1, 160)
How do I do this?
I have a tensor sized (1, 160) I need to resize it to (20, 20, and divide each of the 4 corresponding (20, 20) tensors by a different number, and then resize the tensor and return it as (1, 160)
How do I do this?
I feel your tensor size should be (1,1600).
Assuming it is.
import torch
import random
x = torch.randint(0,200,(1,1600))
x = x.reshape(4,20,20)
for i in range(4):
x[i]/=random.randint(1,200)
x = x.reshape(4,20,20)
Hope this is what you were looking for.