I have a pytorch tensor: x = torch.zeros(2, 2)
, and another tensor of variable values: item = torch.tensor([[1, 2], [3, 4]])
, I am just giving this tensor for example.
I would like add the item
tensor as each element of the x tensor, such that
x = [[item, item],
[item, item]]
So x is a tensor with tensors inside it.
I have tried assigning item
directly to x, but got an error: RuntimeError: The expanded size of the tensor must match the existing size at non-singleton dimension