File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1
1
from __future__ import print_function , division , absolute_import
2
2
import torch
3
3
import torch .nn as nn
4
+ import torch .nn .functional as F
4
5
import torch .utils .model_zoo as model_zoo
5
6
import os
6
7
import sys
@@ -294,11 +295,12 @@ def __init__(self, num_classes=1001):
294
295
Inception_C (),
295
296
Inception_C ()
296
297
)
297
- self .avg_pool = nn .AvgPool2d (8 , count_include_pad = False )
298
298
self .last_linear = nn .Linear (1536 , num_classes )
299
299
300
300
def logits (self , features ):
301
- x = self .avg_pool (features )
301
+ #Allows image of any size to be processed
302
+ adaptiveAvgPoolWidth = features .shape [2 ]
303
+ x = F .avg_pool2d (features , kernel_size = adaptiveAvgPoolWidth )
302
304
x = x .view (x .size (0 ), - 1 )
303
305
x = self .last_linear (x )
304
306
return x
@@ -353,4 +355,4 @@ def inceptionv4(num_classes=1000, pretrained='imagenet'):
353
355
print ('success' )
354
356
355
357
# fail
356
- assert inceptionv4 (num_classes = 1001 , pretrained = 'imagenet' )
358
+ assert inceptionv4 (num_classes = 1001 , pretrained = 'imagenet' )
You can’t perform that action at this time.
0 commit comments