Why (or when) to use unsqueeze ( ) in pytorch?

Why (or when) to use Unsqueeze in pytorch ?

If you want to run your model on a single image. You can load the image and then use unsqueeze to add the batch dimension in the starting. You can also use unsqueeze during broadcasting to make sure the things are broadcasted as you want.

1 Like