Skip to content

Commit 985d0e8

Browse files
committed
Added identity to support older versions of pytorch
1 parent a11fc4c commit 985d0e8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

efficientnet_pytorch/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,22 @@ def __init__(self, in_channels, out_channels, kernel_size, image_size=None, **kw
119119
if pad_h > 0 or pad_w > 0:
120120
self.static_padding = nn.ZeroPad2d((pad_w // 2, pad_w - pad_w // 2, pad_h // 2, pad_h - pad_h // 2))
121121
else:
122-
self.static_padding = nn.Identity()
122+
self.static_padding = Identity()
123123

124124
def forward(self, x):
125125
x = self.static_padding(x)
126126
x = F.conv2d(x, self.weight, self.bias, self.stride, self.padding, self.dilation, self.groups)
127127
return x
128128

129129

130+
class Identity(nn.Module):
131+
def __init__(self,):
132+
super(Identity, self).__init__()
133+
134+
def forward(self, input):
135+
return input
136+
137+
130138
########################################################################
131139
############## HELPERS FUNCTIONS FOR LOADING MODEL PARAMS ##############
132140
########################################################################

0 commit comments

Comments
 (0)