Some problem with iteration by Tensor

batch_in = torch.zeros((3, 3, 1))

batch_in[0] = torch.Tensor([1, 2, 3])
batch_in[1] = torch.Tensor([1, 2, 0])
batch_in[2] = torch.Tensor([1, 0, 0])

I got error:

RuntimeError: The expanded size of the tensor (1) must match the existing size (3) at non-singleton dimension 1

Why?

The dimension of batch_in[0] is [3, 1], so you have to make sure to assign a tensor with the same dims:

batch_in[0] = torch.Tensor([[1], [2], [3]])