Tip
Read more into broadcasting semantics
torch.stack(tensors)
stacks a series of tensors along a new dimension
x = tensor([[ 0.3367, 0.1288, 0.2345], [ 0.2303, -1.1229, -0.1863]])
x = torch.stack((x, x)) # same as torch.stack((x, x), dim=0)
print(x)
tensor([
[[ 0.3367, 0.1288, 0.2345], [ 0.2303, -1.1229, -0.1863]],
[[ 0.3367, 0.1288, 0.2345], [ 0.2303, -1.1229, -0.1863]]
])
It’s the opposite of torch.cat()
torch.tensor(list)
creates a tensor from data (still the same old list but now its a tensor lol)
8/28/24