Dhruv Vashist
Dhruv Vashist

Reputation: 151

Default input dimensions for an image in Neural networks?

Reading a PyTorch book, I came across this code where the authors change the order of the axis.

img_t.permute(1, 2, 0) (Changes the order of the axes from C × H × W to H × W × C)

Is H x W x C the default input dimensions for an input image in Neural networks?

Upvotes: 0

Views: 88

Answers (1)

Anvar Ganiev
Anvar Ganiev

Reputation: 189

In PyTorch inputs are bathes in shape N x C x H x W. So N is a batch size, C is a number of image channels, H and W are height and width as you know. But when you work with for instance cv2, default shape of images is HxWxC so you need to swap dimensions for pytorch.

Upvotes: 1

Related Questions