-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
在教程1-2的代码块In 7中,注释为# Pytorch的图片默认顺序是 Batch,Channel,Width,Height, 这和Pytorch一些文档不符
- Tensor image are expected to be of shape (C, H, W), where C is the number of channels, and H and W refer to height and width. Most transforms support batched tensor input. A batch of Tensor images is a tensor of shape (N, C, H, W), where N is a number of images in the batch. ( 参考https://docs.pytorch.org/vision/stable/transforms.html#torchvision.transforms.ToTensor )
- In PyTorch, images are represented as [channels, height, width], so a color image would be [3, 256, 256].
During the training you will get batches of images, so your shape in the forward method will get an additional batch dimension at dim0: [batch_size, channels, height, width] ( 参考https://discuss.pytorch.org/t/dimensions-of-an-input-image/19439 )
在该代码块前面的变换定义中:
transform_img = T.Compose(
[T.ToTensor()])ToTensor() 也是将图片从HxWxC变换到CxHxW
因为教程中图片是32x32的,H,W交换可能不会导致bug。
为了避免大家学习时误解,建议check一下
Metadata
Metadata
Assignees
Labels
No labels