Skip to content

Commit efd1bfe

Browse files
lopuhinsoumith
authored andcommitted
Fix inception v3 input transform (#144)
First dimension is batch size, channel is the second
1 parent 3549aef commit efd1bfe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

torchvision/models/inception.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def __init__(self, num_classes=1000, aux_logits=True, transform_input=False):
7070
def forward(self, x):
7171
if self.transform_input:
7272
x = x.clone()
73-
x[0] = x[0] * (0.229 / 0.5) + (0.485 - 0.5) / 0.5
74-
x[1] = x[1] * (0.224 / 0.5) + (0.456 - 0.5) / 0.5
75-
x[2] = x[2] * (0.225 / 0.5) + (0.406 - 0.5) / 0.5
73+
x[:, 0] = x[:, 0] * (0.229 / 0.5) + (0.485 - 0.5) / 0.5
74+
x[:, 1] = x[:, 1] * (0.224 / 0.5) + (0.456 - 0.5) / 0.5
75+
x[:, 2] = x[:, 2] * (0.225 / 0.5) + (0.406 - 0.5) / 0.5
7676
# 299 x 299 x 3
7777
x = self.Conv2d_1a_3x3(x)
7878
# 149 x 149 x 32

0 commit comments

Comments
 (0)