Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions torchvision/models/inception.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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
Expand Down Expand Up @@ -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)
# 299 x 299 x 3
# N x 3 x 299 x 299
x = self.Conv2d_1a_3x3(x)
# 149 x 149 x 32
# N x 32 x 149 x 149
x = self.Conv2d_2a_3x3(x)
# 147 x 147 x 32
# N x 32 x 147 x 147
x = self.Conv2d_2b_3x3(x)
# 147 x 147 x 64
# N x 64 x 147 x 147
x = F.max_pool2d(x, kernel_size=3, stride=2)
# 73 x 73 x 64
# N x 64 x 73 x 73
x = self.Conv2d_3b_1x1(x)
# 73 x 73 x 80
# N x 80 x 73 x 73
x = self.Conv2d_4a_3x3(x)
# 71 x 71 x 192
# N x 192 x 71 x 71
x = F.max_pool2d(x, kernel_size=3, stride=2)
# 35 x 35 x 192
# N x 192 x 35 x 35
x = self.Mixed_5b(x)
# 35 x 35 x 256
# N x 256 x 35 x 35
x = self.Mixed_5c(x)
# 35 x 35 x 288
# N x 288 x 35 x 35
x = self.Mixed_5d(x)
# 35 x 35 x 288
# N x 288 x 35 x 35
x = self.Mixed_6a(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
x = self.Mixed_6b(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
x = self.Mixed_6c(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
x = self.Mixed_6d(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
x = self.Mixed_6e(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
if self.training and self.aux_logits:
aux = self.AuxLogits(x)
# 17 x 17 x 768
# N x 768 x 17 x 17
x = self.Mixed_7a(x)
# 8 x 8 x 1280
# N x 1280 x 8 x 8
x = self.Mixed_7b(x)
# 8 x 8 x 2048
# N x 2048 x 8 x 8
x = self.Mixed_7c(x)
# 8 x 8 x 2048
# N x 2048 x 8 x 8
# Adaptive average pooling
x = F.adaptive_avg_pool2d(x, (1, 1))
# 1 x 1 x 2048
# N x 2048 x 1 x 1
x = F.dropout(x, training=self.training)
# 1 x 1 x 2048
# 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
Expand Down Expand Up @@ -305,20 +305,20 @@ def __init__(self, in_channels, num_classes):
self.fc.stddev = 0.001

def forward(self, x):
# 17 x 17 x 768
# N x 768 x 17 x 17
x = F.avg_pool2d(x, kernel_size=5, stride=3)
# 5 x 5 x 768
# N x 768 x 5 x 5
x = self.conv0(x)
# 5 x 5 x 128
# N x 128 x 5 x 5
x = self.conv1(x)
# 1 x 1 x 768
# N x 768 x 1 x 1
# Adaptive average pooling
x = F.adaptive_avg_pool2d(x, (1, 1))
# 1 x 1 x 768
# 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


Expand Down