Exercise

Using the flatten layer

Image data requires some preprocessing before it can be fed into a fully connected neural network. In this exercise, you will need to permute an image's dimensions and flatten it.

An image tensor has already been created, with the following format: N x H x W x C. The order of variables in this format is (0, 1, 2, 3). The torch.nn as nn package has already been imported.

Instructions

100 XP
  • Permute the image tensors dimensions to N x C x H x W by passing the new order to image.permute()
  • Flatten the image tensor.