File tree 1 file changed +3
-6
lines changed
1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ def __init__(self,
39
39
layers is fully convolutional, it should be able to handle inputs
40
40
of arbitrary size, so resizing might not be strictly needed
41
41
normalize_input : bool
42
- If true, normalizes the input to the statistics the pretrained
43
- Inception network expects
42
+ If true, scales the input from range (0, 1) to the range the
43
+ pretrained Inception network expects, namely (-1, 1)
44
44
requires_grad : bool
45
45
If true, parameters of the model require gradient. Possibly useful
46
46
for finetuning the network
@@ -128,10 +128,7 @@ def forward(self, inp):
128
128
align_corners = False )
129
129
130
130
if self .normalize_input :
131
- x = x .clone ()
132
- x [:, 0 ] = x [:, 0 ] * (0.229 / 0.5 ) + (0.485 - 0.5 ) / 0.5
133
- x [:, 1 ] = x [:, 1 ] * (0.224 / 0.5 ) + (0.456 - 0.5 ) / 0.5
134
- x [:, 2 ] = x [:, 2 ] * (0.225 / 0.5 ) + (0.406 - 0.5 ) / 0.5
131
+ x = 2 * x - 1 # Scale from range (0, 1) to range (-1, 1)
135
132
136
133
for idx , block in enumerate (self .blocks ):
137
134
x = block (x )
You can’t perform that action at this time.
0 commit comments