What is the difference between [None, ...] and .unsqueeze(0) when adding a new dimension to data?
[None, ...]
.unsqueeze(0)
In my test, both methods share the original storage and .unsqueeze(0) is slightly faster. Is [None, ...] just a wrapper of .unsqueeze()?
.unsqueeze()
Thanks.
Hi,
[None, ...] is numpy notation for .unsqueeze(0). The two are equivalent. The version with advanced indexing might be a bit slower because it has more checking to do to find out exactly what you want to do.