Can i save tuple in tensor?


#1

is there a way to put tuple in tensor?
e.g.
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:

https://pytorch.org/docs/stable/tensor_attributes.html#tensor-attributes-doc