Can i save tuple in tensor?


is there a way to put tuple in tensor?
FM = torch.ones(1,4,3,3)
FM[0,0,1,1] = (2,2)

(Alwyn Mathew) #2

I don’t think we can.

Instead, you may use the tensor list.

FM = [torch.ones(1,4,3,3) for i in range(2)]
FM[0][0,0,1,1] = 2
FM[1][0,0,1,1] = 2

(Novak) #3

No, tensors are restricted to floats and ints, in varying sizes: