-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResNet_ModelClasses.py
317 lines (311 loc) · 30.5 KB
/
ResNet_ModelClasses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
import torch
import torch.nn as nn
import torch.nn.functional as F
class ResNet_50_1by2_nsfw(nn.Module):
def __init__(self):
super(ResNet_50_1by2_nsfw, self).__init__()
self.conv_1 = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=(7, 7), stride=(2, 2), groups=1, bias=True)
self.bn_1 = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block0_branch2a = nn.Conv2d(in_channels=64, out_channels=32, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.conv_stage0_block0_proj_shortcut = nn.Conv2d(in_channels=64, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block0_branch2a = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.bn_stage0_block0_proj_shortcut = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block0_branch2b = nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block0_branch2b = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block0_branch2c = nn.Conv2d(in_channels=32, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block0_branch2c = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block1_branch2a = nn.Conv2d(in_channels=128, out_channels=32, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block1_branch2a = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block1_branch2b = nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block1_branch2b = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block1_branch2c = nn.Conv2d(in_channels=32, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block1_branch2c = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block2_branch2a = nn.Conv2d(in_channels=128, out_channels=32, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block2_branch2a = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block2_branch2b = nn.Conv2d(in_channels=32, out_channels=32, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block2_branch2b = nn.BatchNorm2d(num_features=32, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage0_block2_branch2c = nn.Conv2d(in_channels=32, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage0_block2_branch2c = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block0_proj_shortcut = nn.Conv2d(in_channels=128, out_channels=256, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.conv_stage1_block0_branch2a = nn.Conv2d(in_channels=128, out_channels=64, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.bn_stage1_block0_proj_shortcut = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.bn_stage1_block0_branch2a = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block0_branch2b = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block0_branch2b = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block0_branch2c = nn.Conv2d(in_channels=64, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block0_branch2c = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block1_branch2a = nn.Conv2d(in_channels=256, out_channels=64, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block1_branch2a = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block1_branch2b = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block1_branch2b = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block1_branch2c = nn.Conv2d(in_channels=64, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block1_branch2c = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block2_branch2a = nn.Conv2d(in_channels=256, out_channels=64, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block2_branch2a = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block2_branch2b = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block2_branch2b = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block2_branch2c = nn.Conv2d(in_channels=64, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block2_branch2c = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block3_branch2a = nn.Conv2d(in_channels=256, out_channels=64, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block3_branch2a = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block3_branch2b = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block3_branch2b = nn.BatchNorm2d(num_features=64, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage1_block3_branch2c = nn.Conv2d(in_channels=64, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage1_block3_branch2c = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block0_proj_shortcut = nn.Conv2d(in_channels=256, out_channels=512, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.conv_stage2_block0_branch2a = nn.Conv2d(in_channels=256, out_channels=128, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.bn_stage2_block0_proj_shortcut = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.bn_stage2_block0_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block0_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block0_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block0_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block0_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block1_branch2a = nn.Conv2d(in_channels=512, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block1_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block1_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block1_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block1_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block1_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block2_branch2a = nn.Conv2d(in_channels=512, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block2_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block2_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block2_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block2_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block2_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block3_branch2a = nn.Conv2d(in_channels=512, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block3_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block3_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block3_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block3_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block3_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block4_branch2a = nn.Conv2d(in_channels=512, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block4_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block4_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block4_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block4_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block4_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block5_branch2a = nn.Conv2d(in_channels=512, out_channels=128, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block5_branch2a = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block5_branch2b = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block5_branch2b = nn.BatchNorm2d(num_features=128, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage2_block5_branch2c = nn.Conv2d(in_channels=128, out_channels=512, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage2_block5_branch2c = nn.BatchNorm2d(num_features=512, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block0_proj_shortcut = nn.Conv2d(in_channels=512, out_channels=1024, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.conv_stage3_block0_branch2a = nn.Conv2d(in_channels=512, out_channels=256, kernel_size=(1, 1), stride=(2, 2), groups=1, bias=True)
self.bn_stage3_block0_proj_shortcut = nn.BatchNorm2d(num_features=1024, eps=9.999999747378752e-06, momentum=0.0)
self.bn_stage3_block0_branch2a = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block0_branch2b = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block0_branch2b = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block0_branch2c = nn.Conv2d(in_channels=256, out_channels=1024, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block0_branch2c = nn.BatchNorm2d(num_features=1024, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block1_branch2a = nn.Conv2d(in_channels=1024, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block1_branch2a = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block1_branch2b = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block1_branch2b = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block1_branch2c = nn.Conv2d(in_channels=256, out_channels=1024, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block1_branch2c = nn.BatchNorm2d(num_features=1024, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block2_branch2a = nn.Conv2d(in_channels=1024, out_channels=256, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block2_branch2a = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block2_branch2b = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block2_branch2b = nn.BatchNorm2d(num_features=256, eps=9.999999747378752e-06, momentum=0.0)
self.conv_stage3_block2_branch2c = nn.Conv2d(in_channels=256, out_channels=1024, kernel_size=(1, 1), stride=(1, 1), groups=1, bias=True)
self.bn_stage3_block2_branch2c = nn.BatchNorm2d(num_features=1024, eps=9.999999747378752e-06, momentum=0.0)
self.fc_nsfw_1 = nn.Linear(in_features = 1024, out_features = 2, bias = True)
def forward(self, x):
conv_1_pad = F.pad(x, (3, 3, 3, 3))
conv_1 = self.conv_1(conv_1_pad)
bn_1 = self.bn_1(conv_1)
relu_1 = F.relu(bn_1)
pool1_pad = F.pad(relu_1, (0, 1, 0, 1), value=float('-inf'))
pool1 = F.max_pool2d(pool1_pad, kernel_size=(3, 3), stride=(2, 2), padding=0, ceil_mode=False)
conv_stage0_block0_branch2a = self.conv_stage0_block0_branch2a(pool1)
conv_stage0_block0_proj_shortcut = self.conv_stage0_block0_proj_shortcut(pool1)
bn_stage0_block0_branch2a = self.bn_stage0_block0_branch2a(conv_stage0_block0_branch2a)
bn_stage0_block0_proj_shortcut = self.bn_stage0_block0_proj_shortcut(conv_stage0_block0_proj_shortcut)
relu_stage0_block0_branch2a = F.relu(bn_stage0_block0_branch2a)
conv_stage0_block0_branch2b_pad = F.pad(relu_stage0_block0_branch2a, (1, 1, 1, 1))
conv_stage0_block0_branch2b = self.conv_stage0_block0_branch2b(conv_stage0_block0_branch2b_pad)
bn_stage0_block0_branch2b = self.bn_stage0_block0_branch2b(conv_stage0_block0_branch2b)
relu_stage0_block0_branch2b = F.relu(bn_stage0_block0_branch2b)
conv_stage0_block0_branch2c = self.conv_stage0_block0_branch2c(relu_stage0_block0_branch2b)
bn_stage0_block0_branch2c = self.bn_stage0_block0_branch2c(conv_stage0_block0_branch2c)
eltwise_stage0_block0 = bn_stage0_block0_proj_shortcut + bn_stage0_block0_branch2c
relu_stage0_block0 = F.relu(eltwise_stage0_block0)
conv_stage0_block1_branch2a = self.conv_stage0_block1_branch2a(relu_stage0_block0)
bn_stage0_block1_branch2a = self.bn_stage0_block1_branch2a(conv_stage0_block1_branch2a)
relu_stage0_block1_branch2a = F.relu(bn_stage0_block1_branch2a)
conv_stage0_block1_branch2b_pad = F.pad(relu_stage0_block1_branch2a, (1, 1, 1, 1))
conv_stage0_block1_branch2b = self.conv_stage0_block1_branch2b(conv_stage0_block1_branch2b_pad)
bn_stage0_block1_branch2b = self.bn_stage0_block1_branch2b(conv_stage0_block1_branch2b)
relu_stage0_block1_branch2b = F.relu(bn_stage0_block1_branch2b)
conv_stage0_block1_branch2c = self.conv_stage0_block1_branch2c(relu_stage0_block1_branch2b)
bn_stage0_block1_branch2c = self.bn_stage0_block1_branch2c(conv_stage0_block1_branch2c)
eltwise_stage0_block1 = relu_stage0_block0 + bn_stage0_block1_branch2c
relu_stage0_block1 = F.relu(eltwise_stage0_block1)
conv_stage0_block2_branch2a = self.conv_stage0_block2_branch2a(relu_stage0_block1)
bn_stage0_block2_branch2a = self.bn_stage0_block2_branch2a(conv_stage0_block2_branch2a)
relu_stage0_block2_branch2a = F.relu(bn_stage0_block2_branch2a)
conv_stage0_block2_branch2b_pad = F.pad(relu_stage0_block2_branch2a, (1, 1, 1, 1))
conv_stage0_block2_branch2b = self.conv_stage0_block2_branch2b(conv_stage0_block2_branch2b_pad)
bn_stage0_block2_branch2b = self.bn_stage0_block2_branch2b(conv_stage0_block2_branch2b)
relu_stage0_block2_branch2b = F.relu(bn_stage0_block2_branch2b)
conv_stage0_block2_branch2c = self.conv_stage0_block2_branch2c(relu_stage0_block2_branch2b)
bn_stage0_block2_branch2c = self.bn_stage0_block2_branch2c(conv_stage0_block2_branch2c)
eltwise_stage0_block2 = relu_stage0_block1 + bn_stage0_block2_branch2c
relu_stage0_block2 = F.relu(eltwise_stage0_block2)
conv_stage1_block0_proj_shortcut = self.conv_stage1_block0_proj_shortcut(relu_stage0_block2)
conv_stage1_block0_branch2a = self.conv_stage1_block0_branch2a(relu_stage0_block2)
bn_stage1_block0_proj_shortcut = self.bn_stage1_block0_proj_shortcut(conv_stage1_block0_proj_shortcut)
bn_stage1_block0_branch2a = self.bn_stage1_block0_branch2a(conv_stage1_block0_branch2a)
relu_stage1_block0_branch2a = F.relu(bn_stage1_block0_branch2a)
conv_stage1_block0_branch2b_pad = F.pad(relu_stage1_block0_branch2a, (1, 1, 1, 1))
conv_stage1_block0_branch2b = self.conv_stage1_block0_branch2b(conv_stage1_block0_branch2b_pad)
bn_stage1_block0_branch2b = self.bn_stage1_block0_branch2b(conv_stage1_block0_branch2b)
relu_stage1_block0_branch2b = F.relu(bn_stage1_block0_branch2b)
conv_stage1_block0_branch2c = self.conv_stage1_block0_branch2c(relu_stage1_block0_branch2b)
bn_stage1_block0_branch2c = self.bn_stage1_block0_branch2c(conv_stage1_block0_branch2c)
eltwise_stage1_block0 = bn_stage1_block0_proj_shortcut + bn_stage1_block0_branch2c
relu_stage1_block0 = F.relu(eltwise_stage1_block0)
conv_stage1_block1_branch2a = self.conv_stage1_block1_branch2a(relu_stage1_block0)
bn_stage1_block1_branch2a = self.bn_stage1_block1_branch2a(conv_stage1_block1_branch2a)
relu_stage1_block1_branch2a = F.relu(bn_stage1_block1_branch2a)
conv_stage1_block1_branch2b_pad = F.pad(relu_stage1_block1_branch2a, (1, 1, 1, 1))
conv_stage1_block1_branch2b = self.conv_stage1_block1_branch2b(conv_stage1_block1_branch2b_pad)
bn_stage1_block1_branch2b = self.bn_stage1_block1_branch2b(conv_stage1_block1_branch2b)
relu_stage1_block1_branch2b = F.relu(bn_stage1_block1_branch2b)
conv_stage1_block1_branch2c = self.conv_stage1_block1_branch2c(relu_stage1_block1_branch2b)
bn_stage1_block1_branch2c = self.bn_stage1_block1_branch2c(conv_stage1_block1_branch2c)
eltwise_stage1_block1 = relu_stage1_block0 + bn_stage1_block1_branch2c
relu_stage1_block1 = F.relu(eltwise_stage1_block1)
conv_stage1_block2_branch2a = self.conv_stage1_block2_branch2a(relu_stage1_block1)
bn_stage1_block2_branch2a = self.bn_stage1_block2_branch2a(conv_stage1_block2_branch2a)
relu_stage1_block2_branch2a = F.relu(bn_stage1_block2_branch2a)
conv_stage1_block2_branch2b_pad = F.pad(relu_stage1_block2_branch2a, (1, 1, 1, 1))
conv_stage1_block2_branch2b = self.conv_stage1_block2_branch2b(conv_stage1_block2_branch2b_pad)
bn_stage1_block2_branch2b = self.bn_stage1_block2_branch2b(conv_stage1_block2_branch2b)
relu_stage1_block2_branch2b = F.relu(bn_stage1_block2_branch2b)
conv_stage1_block2_branch2c = self.conv_stage1_block2_branch2c(relu_stage1_block2_branch2b)
bn_stage1_block2_branch2c = self.bn_stage1_block2_branch2c(conv_stage1_block2_branch2c)
eltwise_stage1_block2 = relu_stage1_block1 + bn_stage1_block2_branch2c
relu_stage1_block2 = F.relu(eltwise_stage1_block2)
conv_stage1_block3_branch2a = self.conv_stage1_block3_branch2a(relu_stage1_block2)
bn_stage1_block3_branch2a = self.bn_stage1_block3_branch2a(conv_stage1_block3_branch2a)
relu_stage1_block3_branch2a = F.relu(bn_stage1_block3_branch2a)
conv_stage1_block3_branch2b_pad = F.pad(relu_stage1_block3_branch2a, (1, 1, 1, 1))
conv_stage1_block3_branch2b = self.conv_stage1_block3_branch2b(conv_stage1_block3_branch2b_pad)
bn_stage1_block3_branch2b = self.bn_stage1_block3_branch2b(conv_stage1_block3_branch2b)
relu_stage1_block3_branch2b = F.relu(bn_stage1_block3_branch2b)
conv_stage1_block3_branch2c = self.conv_stage1_block3_branch2c(relu_stage1_block3_branch2b)
bn_stage1_block3_branch2c = self.bn_stage1_block3_branch2c(conv_stage1_block3_branch2c)
eltwise_stage1_block3 = relu_stage1_block2 + bn_stage1_block3_branch2c
relu_stage1_block3 = F.relu(eltwise_stage1_block3)
conv_stage2_block0_proj_shortcut = self.conv_stage2_block0_proj_shortcut(relu_stage1_block3)
conv_stage2_block0_branch2a = self.conv_stage2_block0_branch2a(relu_stage1_block3)
bn_stage2_block0_proj_shortcut = self.bn_stage2_block0_proj_shortcut(conv_stage2_block0_proj_shortcut)
bn_stage2_block0_branch2a = self.bn_stage2_block0_branch2a(conv_stage2_block0_branch2a)
relu_stage2_block0_branch2a = F.relu(bn_stage2_block0_branch2a)
conv_stage2_block0_branch2b_pad = F.pad(relu_stage2_block0_branch2a, (1, 1, 1, 1))
conv_stage2_block0_branch2b = self.conv_stage2_block0_branch2b(conv_stage2_block0_branch2b_pad)
bn_stage2_block0_branch2b = self.bn_stage2_block0_branch2b(conv_stage2_block0_branch2b)
relu_stage2_block0_branch2b = F.relu(bn_stage2_block0_branch2b)
conv_stage2_block0_branch2c = self.conv_stage2_block0_branch2c(relu_stage2_block0_branch2b)
bn_stage2_block0_branch2c = self.bn_stage2_block0_branch2c(conv_stage2_block0_branch2c)
eltwise_stage2_block0 = bn_stage2_block0_proj_shortcut + bn_stage2_block0_branch2c
relu_stage2_block0 = F.relu(eltwise_stage2_block0)
conv_stage2_block1_branch2a = self.conv_stage2_block1_branch2a(relu_stage2_block0)
bn_stage2_block1_branch2a = self.bn_stage2_block1_branch2a(conv_stage2_block1_branch2a)
relu_stage2_block1_branch2a = F.relu(bn_stage2_block1_branch2a)
conv_stage2_block1_branch2b_pad = F.pad(relu_stage2_block1_branch2a, (1, 1, 1, 1))
conv_stage2_block1_branch2b = self.conv_stage2_block1_branch2b(conv_stage2_block1_branch2b_pad)
bn_stage2_block1_branch2b = self.bn_stage2_block1_branch2b(conv_stage2_block1_branch2b)
relu_stage2_block1_branch2b = F.relu(bn_stage2_block1_branch2b)
conv_stage2_block1_branch2c = self.conv_stage2_block1_branch2c(relu_stage2_block1_branch2b)
bn_stage2_block1_branch2c = self.bn_stage2_block1_branch2c(conv_stage2_block1_branch2c)
eltwise_stage2_block1 = relu_stage2_block0 + bn_stage2_block1_branch2c
relu_stage2_block1 = F.relu(eltwise_stage2_block1)
conv_stage2_block2_branch2a = self.conv_stage2_block2_branch2a(relu_stage2_block1)
bn_stage2_block2_branch2a = self.bn_stage2_block2_branch2a(conv_stage2_block2_branch2a)
relu_stage2_block2_branch2a = F.relu(bn_stage2_block2_branch2a)
conv_stage2_block2_branch2b_pad = F.pad(relu_stage2_block2_branch2a, (1, 1, 1, 1))
conv_stage2_block2_branch2b = self.conv_stage2_block2_branch2b(conv_stage2_block2_branch2b_pad)
bn_stage2_block2_branch2b = self.bn_stage2_block2_branch2b(conv_stage2_block2_branch2b)
relu_stage2_block2_branch2b = F.relu(bn_stage2_block2_branch2b)
conv_stage2_block2_branch2c = self.conv_stage2_block2_branch2c(relu_stage2_block2_branch2b)
bn_stage2_block2_branch2c = self.bn_stage2_block2_branch2c(conv_stage2_block2_branch2c)
eltwise_stage2_block2 = relu_stage2_block1 + bn_stage2_block2_branch2c
relu_stage2_block2 = F.relu(eltwise_stage2_block2)
conv_stage2_block3_branch2a = self.conv_stage2_block3_branch2a(relu_stage2_block2)
bn_stage2_block3_branch2a = self.bn_stage2_block3_branch2a(conv_stage2_block3_branch2a)
relu_stage2_block3_branch2a = F.relu(bn_stage2_block3_branch2a)
conv_stage2_block3_branch2b_pad = F.pad(relu_stage2_block3_branch2a, (1, 1, 1, 1))
conv_stage2_block3_branch2b = self.conv_stage2_block3_branch2b(conv_stage2_block3_branch2b_pad)
bn_stage2_block3_branch2b = self.bn_stage2_block3_branch2b(conv_stage2_block3_branch2b)
relu_stage2_block3_branch2b = F.relu(bn_stage2_block3_branch2b)
conv_stage2_block3_branch2c = self.conv_stage2_block3_branch2c(relu_stage2_block3_branch2b)
bn_stage2_block3_branch2c = self.bn_stage2_block3_branch2c(conv_stage2_block3_branch2c)
eltwise_stage2_block3 = relu_stage2_block2 + bn_stage2_block3_branch2c
relu_stage2_block3 = F.relu(eltwise_stage2_block3)
conv_stage2_block4_branch2a = self.conv_stage2_block4_branch2a(relu_stage2_block3)
bn_stage2_block4_branch2a = self.bn_stage2_block4_branch2a(conv_stage2_block4_branch2a)
relu_stage2_block4_branch2a = F.relu(bn_stage2_block4_branch2a)
conv_stage2_block4_branch2b_pad = F.pad(relu_stage2_block4_branch2a, (1, 1, 1, 1))
conv_stage2_block4_branch2b = self.conv_stage2_block4_branch2b(conv_stage2_block4_branch2b_pad)
bn_stage2_block4_branch2b = self.bn_stage2_block4_branch2b(conv_stage2_block4_branch2b)
relu_stage2_block4_branch2b = F.relu(bn_stage2_block4_branch2b)
conv_stage2_block4_branch2c = self.conv_stage2_block4_branch2c(relu_stage2_block4_branch2b)
bn_stage2_block4_branch2c = self.bn_stage2_block4_branch2c(conv_stage2_block4_branch2c)
eltwise_stage2_block4 = relu_stage2_block3 + bn_stage2_block4_branch2c
relu_stage2_block4 = F.relu(eltwise_stage2_block4)
conv_stage2_block5_branch2a = self.conv_stage2_block5_branch2a(relu_stage2_block4)
bn_stage2_block5_branch2a = self.bn_stage2_block5_branch2a(conv_stage2_block5_branch2a)
relu_stage2_block5_branch2a = F.relu(bn_stage2_block5_branch2a)
conv_stage2_block5_branch2b_pad = F.pad(relu_stage2_block5_branch2a, (1, 1, 1, 1))
conv_stage2_block5_branch2b = self.conv_stage2_block5_branch2b(conv_stage2_block5_branch2b_pad)
bn_stage2_block5_branch2b = self.bn_stage2_block5_branch2b(conv_stage2_block5_branch2b)
relu_stage2_block5_branch2b = F.relu(bn_stage2_block5_branch2b)
conv_stage2_block5_branch2c = self.conv_stage2_block5_branch2c(relu_stage2_block5_branch2b)
bn_stage2_block5_branch2c = self.bn_stage2_block5_branch2c(conv_stage2_block5_branch2c)
eltwise_stage2_block5 = relu_stage2_block4 + bn_stage2_block5_branch2c
relu_stage2_block5 = F.relu(eltwise_stage2_block5)
conv_stage3_block0_proj_shortcut = self.conv_stage3_block0_proj_shortcut(relu_stage2_block5)
conv_stage3_block0_branch2a = self.conv_stage3_block0_branch2a(relu_stage2_block5)
bn_stage3_block0_proj_shortcut = self.bn_stage3_block0_proj_shortcut(conv_stage3_block0_proj_shortcut)
bn_stage3_block0_branch2a = self.bn_stage3_block0_branch2a(conv_stage3_block0_branch2a)
relu_stage3_block0_branch2a = F.relu(bn_stage3_block0_branch2a)
conv_stage3_block0_branch2b_pad = F.pad(relu_stage3_block0_branch2a, (1, 1, 1, 1))
conv_stage3_block0_branch2b = self.conv_stage3_block0_branch2b(conv_stage3_block0_branch2b_pad)
bn_stage3_block0_branch2b = self.bn_stage3_block0_branch2b(conv_stage3_block0_branch2b)
relu_stage3_block0_branch2b = F.relu(bn_stage3_block0_branch2b)
conv_stage3_block0_branch2c = self.conv_stage3_block0_branch2c(relu_stage3_block0_branch2b)
bn_stage3_block0_branch2c = self.bn_stage3_block0_branch2c(conv_stage3_block0_branch2c)
eltwise_stage3_block0 = bn_stage3_block0_proj_shortcut + bn_stage3_block0_branch2c
relu_stage3_block0 = F.relu(eltwise_stage3_block0)
conv_stage3_block1_branch2a = self.conv_stage3_block1_branch2a(relu_stage3_block0)
bn_stage3_block1_branch2a = self.bn_stage3_block1_branch2a(conv_stage3_block1_branch2a)
relu_stage3_block1_branch2a = F.relu(bn_stage3_block1_branch2a)
conv_stage3_block1_branch2b_pad = F.pad(relu_stage3_block1_branch2a, (1, 1, 1, 1))
conv_stage3_block1_branch2b = self.conv_stage3_block1_branch2b(conv_stage3_block1_branch2b_pad)
bn_stage3_block1_branch2b = self.bn_stage3_block1_branch2b(conv_stage3_block1_branch2b)
relu_stage3_block1_branch2b = F.relu(bn_stage3_block1_branch2b)
conv_stage3_block1_branch2c = self.conv_stage3_block1_branch2c(relu_stage3_block1_branch2b)
bn_stage3_block1_branch2c = self.bn_stage3_block1_branch2c(conv_stage3_block1_branch2c)
eltwise_stage3_block1 = relu_stage3_block0 + bn_stage3_block1_branch2c
relu_stage3_block1 = F.relu(eltwise_stage3_block1)
conv_stage3_block2_branch2a = self.conv_stage3_block2_branch2a(relu_stage3_block1)
bn_stage3_block2_branch2a = self.bn_stage3_block2_branch2a(conv_stage3_block2_branch2a)
relu_stage3_block2_branch2a = F.relu(bn_stage3_block2_branch2a)
conv_stage3_block2_branch2b_pad = F.pad(relu_stage3_block2_branch2a, (1, 1, 1, 1))
conv_stage3_block2_branch2b = self.conv_stage3_block2_branch2b(conv_stage3_block2_branch2b_pad)
bn_stage3_block2_branch2b = self.bn_stage3_block2_branch2b(conv_stage3_block2_branch2b)
relu_stage3_block2_branch2b = F.relu(bn_stage3_block2_branch2b)
conv_stage3_block2_branch2c = self.conv_stage3_block2_branch2c(relu_stage3_block2_branch2b)
bn_stage3_block2_branch2c = self.bn_stage3_block2_branch2c(conv_stage3_block2_branch2c)
eltwise_stage3_block2 = relu_stage3_block1 + bn_stage3_block2_branch2c
relu_stage3_block2 = F.relu(eltwise_stage3_block2)
avgpool_2d = nn.AdaptiveAvgPool2d((7, 7))
relu_stage3_block2 = avgpool_2d(relu_stage3_block2)
pool = F.avg_pool2d(relu_stage3_block2, kernel_size=(7, 7), stride=(1, 1), padding=(0,), ceil_mode=False, count_include_pad=False)
fc_nsfw_0 = pool.view(pool.size(0), -1)
fc_nsfw_1 = self.fc_nsfw_1(fc_nsfw_0)
prob = F.softmax(fc_nsfw_1)
return prob