This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Model2.py
54 lines (49 loc) · 2.06 KB
/
Model2.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
import torch
import torch.nn as nn
class CustomModel2(nn.Module):
def __init__(self):
super(CustomModel2, self).__init__()
self.conv1 = nn.Conv2d(in_channels=3, out_channels=256, kernel_size=3, stride=1, padding=1, bias=False)
self.relu1 = nn.PReLU()
self.avgpool1 = nn.AvgPool2d(2, stride=2)
self.conv2 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=3, stride=2, padding=1, bias=False)
self.relu2 = nn.PReLU()
self.avgpool2 = nn.AvgPool2d(2, stride=2)
self.conv3 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=1, stride=1, padding=0, bias=False)
self.relu3 = nn.PReLU()
self.avgpool3 = nn.AvgPool2d(2, stride=2)
self.conv4 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=3, stride=1, padding=1, bias=False)
self.relu4 = nn.PReLU()
self.subpixel = nn.PixelShuffle(2)
self.conv_output = nn.Conv2d(in_channels=64, out_channels=3, kernel_size=3, stride=1, padding=1, bias=False)
#self.subpixel = nn.PixelShuffle(16)
#self.conv_output = nn.Conv2d(in_channels=1, out_channels=3, kernel_size=3, stride=1, padding=1, bias=False)
def forward(self, x):
item = x
print("DEBUT")
'''
out = self.avgpool1(self.relu1(self.conv1(x)))
print(out.shape)
out = self.avgpool2(self.relu2(self.conv2(out)))
print(out.shape)
out = self.avgpool3(self.relu3(self.conv3(out)))
'''
out = self.relu1(self.conv1(x))
print(out.shape)
out = self.relu2(self.conv2(out))
print(out.shape)
out = self.relu3(self.conv3(out))
print(out.shape)
residual2 = out
out = self.relu4(self.conv4(out))
print("Avant add")
print(out.shape)
out = torch.add(out, residual2)
print("Après add et avant subpixel")
print(out.shape)
out = self.subpixel(out)
print("Après subpixel")
print(out.shape)
out = self.conv_output(out)
out = torch.add(out, item)
return out