-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModel.py
37 lines (25 loc) · 1.02 KB
/
Model.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
from torch import nn
import torch.nn.functional as F
import torch
import torchvision
import numpy as np
class DNCNN(nn.Module):
def __init__(self, n_channels, n_filters, kernel_size):
super(DNCNN, self).__init__()
layers = [
nn.Conv2d(in_channels=n_channels, out_channels=n_filters, kernel_size=kernel_size,
padding=1, bias=False),
nn.ReLU(inplace=True)
]
depth = 20
for _ in range(depth-2):
layers.append(nn.Conv2d(in_channels=n_filters, out_channels=n_filters, kernel_size=kernel_size,
padding=1, bias=False))
layers.append(nn.BatchNorm2d(n_filters))
layers.append(nn.ReLU(inplace=True))
layers.append(nn.Conv2d(in_channels=n_filters, out_channels=n_channels, kernel_size=kernel_size,
padding=1, bias=False))
self.dncnn = nn.Sequential(*layers)
def forward(self,x):
out = self.dncnn(x)
return out