LoginSignup
9
9

More than 3 years have passed since last update.

pyTorchでlist(torch.Tensor, torch.Tensor, ...)をtorch.Tensorにまとめる

Posted at

全ての要素がlistで完結しているなら何も問題はないと思いますが、tensor in list -> tensorsの際にひっかかったため
なお、list内のtensorは全て同じshapeを持つとします。

arrs = [torch.Tensor(), torch.Tensor(), torch.Tensor(), ...]
arrs = torch.cat(arrs).reshape(len(arrs), *arrs[0].shape)
9
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9