import torch
tensor_list = []
for i in range(3):
tensor_list.append(torch.rand(3))
print(tensor_list)
# [tensor([0.4824, 0.2966, 0.3177]), tensor([0.5601, 0.0189, 0.4304]), tensor([0.9667, 0.4388, 0.2032])]
tensor_list = torch.stack(tensor_list, dim=0) # これ
print(tensor_list)
# tensor([[0.4824, 0.2966, 0.3177],
# [0.5601, 0.0189, 0.4304],
# [0.9667, 0.4388, 0.2032]])
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme