(self, mean, std)
| 279 | # ``nn.Sequential`` |
| 280 | class Normalization(nn.Module): |
| 281 | def __init__(self, mean, std): |
| 282 | super(Normalization, self).__init__() |
| 283 | # .view the mean and std to make them [C x 1 x 1] so that they can |
| 284 | # directly work with image Tensor of shape [B x C x H x W]. |
| 285 | # B is batch size. C is number of channels. H is height and W is width. |
| 286 | self.mean = torch.tensor(mean).view(-1, 1, 1) |
| 287 | self.std = torch.tensor(std).view(-1, 1, 1) |
| 288 | |
| 289 | def forward(self, img): |
| 290 | # normalize ``img`` |