From 597e02d10d0c36962f36e38cf90861858679c8a4 Mon Sep 17 00:00:00 2001 From: ekka Date: Thu, 14 Feb 2019 19:30:20 +0530 Subject: [PATCH 1/3] Modifying the comments of inceptionV3 dimensions Modifying the comments of inceptionV3 dimensions to match the pytorch convention. Relevant (https://github.com/pytorch/vision/pull/719#pullrequestreview-203194302) --- torchvision/models/inception.py | 56 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/torchvision/models/inception.py b/torchvision/models/inception.py index 9c49944a73a..d36fd848c3b 100644 --- a/torchvision/models/inception.py +++ b/torchvision/models/inception.py @@ -19,7 +19,7 @@ def inception_v3(pretrained=False, **kwargs): .. note:: **Important**: In contrast to the other models the inception_v3 expects tensors with a size of - 299x299x3, so ensure your images are sized accordingly. + 3x299x299, so ensure your images are sized accordingly. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet @@ -78,51 +78,51 @@ def forward(self, x): x_ch1 = torch.unsqueeze(x[:, 1], 1) * (0.224 / 0.5) + (0.456 - 0.5) / 0.5 x_ch2 = torch.unsqueeze(x[:, 2], 1) * (0.225 / 0.5) + (0.406 - 0.5) / 0.5 x = torch.cat((x_ch0, x_ch1, x_ch2), 1) - # 299 x 299 x 3 + # 3 x 299 x 299 x = self.Conv2d_1a_3x3(x) - # 149 x 149 x 32 + # 32 x 149 x 149 x = self.Conv2d_2a_3x3(x) - # 147 x 147 x 32 + # 32 x 147 x 147 x = self.Conv2d_2b_3x3(x) - # 147 x 147 x 64 + # 64 x 147 x 147 x = F.max_pool2d(x, kernel_size=3, stride=2) - # 73 x 73 x 64 + # 64 x 73 x 73 x = self.Conv2d_3b_1x1(x) - # 73 x 73 x 80 + # 80 x 73 x 73 x = self.Conv2d_4a_3x3(x) - # 71 x 71 x 192 + # 192 x 71 x 71 x = F.max_pool2d(x, kernel_size=3, stride=2) - # 35 x 35 x 192 + # 192 x 35 x 35 x = self.Mixed_5b(x) - # 35 x 35 x 256 + # 256 x 35 x 35 x = self.Mixed_5c(x) - # 35 x 35 x 288 + # 288 x 35 x 35 x = self.Mixed_5d(x) - # 35 x 35 x 288 + # 288 x 35 x 35 x = self.Mixed_6a(x) - # 17 x 17 x 768 + # 768 x 17 x 17 x = self.Mixed_6b(x) - # 17 x 17 x 768 + # 768 x 17 x 17 x = self.Mixed_6c(x) - # 17 x 17 x 768 + # 768 x 17 x 17 x = self.Mixed_6d(x) - # 17 x 17 x 768 + # 768 x 17 x 17 x = self.Mixed_6e(x) - # 17 x 17 x 768 + # 768 x 17 x 17 if self.training and self.aux_logits: aux = self.AuxLogits(x) - # 17 x 17 x 768 + # 768 x 17 x 17 x = self.Mixed_7a(x) - # 8 x 8 x 1280 + # 1280 x 8 x 8 x = self.Mixed_7b(x) - # 8 x 8 x 2048 + # 2048 x 8 x 8 x = self.Mixed_7c(x) - # 8 x 8 x 2048 + # 2048 x 8 x 8 # Adaptive average pooling x = F.adaptive_avg_pool2d(x, (1, 1)) - # 1 x 1 x 2048 + # 2048 x 1 x 1 x = F.dropout(x, training=self.training) - # 1 x 1 x 2048 + # 2048 x 1 x 1 x = x.view(x.size(0), -1) # 2048 x = self.fc(x) @@ -305,16 +305,16 @@ def __init__(self, in_channels, num_classes): self.fc.stddev = 0.001 def forward(self, x): - # 17 x 17 x 768 + # 768 x 17 x 17 x = F.avg_pool2d(x, kernel_size=5, stride=3) - # 5 x 5 x 768 + # 768 x 5 x 5 x = self.conv0(x) - # 5 x 5 x 128 + # 128 x 5 x 5 x = self.conv1(x) - # 1 x 1 x 768 + # 768 x 1 x 1 # Adaptive average pooling x = F.adaptive_avg_pool2d(x, (1, 1)) - # 1 x 1 x 768 + # 768 x 1 x 1 x = x.view(x.size(0), -1) # 768 x = self.fc(x) From a92edc77e640c8f2edad1f608e8ed59ff377b246 Mon Sep 17 00:00:00 2001 From: ekka Date: Thu, 14 Feb 2019 20:40:07 +0530 Subject: [PATCH 2/3] Added Batch size in comment --- torchvision/models/inception.py | 62 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/torchvision/models/inception.py b/torchvision/models/inception.py index d36fd848c3b..9f9e3d44793 100644 --- a/torchvision/models/inception.py +++ b/torchvision/models/inception.py @@ -78,55 +78,55 @@ def forward(self, x): x_ch1 = torch.unsqueeze(x[:, 1], 1) * (0.224 / 0.5) + (0.456 - 0.5) / 0.5 x_ch2 = torch.unsqueeze(x[:, 2], 1) * (0.225 / 0.5) + (0.406 - 0.5) / 0.5 x = torch.cat((x_ch0, x_ch1, x_ch2), 1) - # 3 x 299 x 299 + # N x 3 x 299 x 299 x = self.Conv2d_1a_3x3(x) - # 32 x 149 x 149 + # N x 32 x 149 x 149 x = self.Conv2d_2a_3x3(x) - # 32 x 147 x 147 + # N x 32 x 147 x 147 x = self.Conv2d_2b_3x3(x) - # 64 x 147 x 147 + # N x 64 x 147 x 147 x = F.max_pool2d(x, kernel_size=3, stride=2) - # 64 x 73 x 73 + # N x 64 x 73 x 73 x = self.Conv2d_3b_1x1(x) - # 80 x 73 x 73 + # N x 80 x 73 x 73 x = self.Conv2d_4a_3x3(x) - # 192 x 71 x 71 + # N x 192 x 71 x 71 x = F.max_pool2d(x, kernel_size=3, stride=2) - # 192 x 35 x 35 + # N x 192 x 35 x 35 x = self.Mixed_5b(x) - # 256 x 35 x 35 + # N x 256 x 35 x 35 x = self.Mixed_5c(x) - # 288 x 35 x 35 + # N x 288 x 35 x 35 x = self.Mixed_5d(x) - # 288 x 35 x 35 + # N x 288 x 35 x 35 x = self.Mixed_6a(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = self.Mixed_6b(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = self.Mixed_6c(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = self.Mixed_6d(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = self.Mixed_6e(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 if self.training and self.aux_logits: aux = self.AuxLogits(x) - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = self.Mixed_7a(x) - # 1280 x 8 x 8 + # N x 1280 x 8 x 8 x = self.Mixed_7b(x) - # 2048 x 8 x 8 + # N x 2048 x 8 x 8 x = self.Mixed_7c(x) - # 2048 x 8 x 8 + # N x 2048 x 8 x 8 # Adaptive average pooling x = F.adaptive_avg_pool2d(x, (1, 1)) - # 2048 x 1 x 1 + # N x 2048 x 1 x 1 x = F.dropout(x, training=self.training) - # 2048 x 1 x 1 + # N x 2048 x 1 x 1 x = x.view(x.size(0), -1) - # 2048 + # N x 2048 x = self.fc(x) - # 1000 (num_classes) + # N x 1000 (num_classes) if self.training and self.aux_logits: return x, aux return x @@ -305,20 +305,20 @@ def __init__(self, in_channels, num_classes): self.fc.stddev = 0.001 def forward(self, x): - # 768 x 17 x 17 + # N x 768 x 17 x 17 x = F.avg_pool2d(x, kernel_size=5, stride=3) - # 768 x 5 x 5 + # N x 768 x 5 x 5 x = self.conv0(x) - # 128 x 5 x 5 + # N x 128 x 5 x 5 x = self.conv1(x) - # 768 x 1 x 1 + # N x 768 x 1 x 1 # Adaptive average pooling x = F.adaptive_avg_pool2d(x, (1, 1)) - # 768 x 1 x 1 + # N x 768 x 1 x 1 x = x.view(x.size(0), -1) - # 768 + # N x 768 x = self.fc(x) - # 1000 + # N x 1000 return x From 21da0ee2aca1a488a216cd077eae8d7d04c5949a Mon Sep 17 00:00:00 2001 From: ekka Date: Thu, 14 Feb 2019 20:41:33 +0530 Subject: [PATCH 3/3] Update inception.py --- torchvision/models/inception.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/models/inception.py b/torchvision/models/inception.py index 9f9e3d44793..e68afff5115 100644 --- a/torchvision/models/inception.py +++ b/torchvision/models/inception.py @@ -19,7 +19,7 @@ def inception_v3(pretrained=False, **kwargs): .. note:: **Important**: In contrast to the other models the inception_v3 expects tensors with a size of - 3x299x299, so ensure your images are sized accordingly. + N x 3 x 299 x 299, so ensure your images are sized accordingly. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet