-
Notifications
You must be signed in to change notification settings - Fork 0
/
discrimenator.py
31 lines (23 loc) · 957 Bytes
/
discrimenator.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
import torch
from torch import nn
import torch.nn.functional as F
class Discrimenator(nn.Module):
def __init__(self, in_img, out_img):
super(Discrimenator, self).__init__()
self.conv = nn.Sequential(
nn.Conv2d(in_img, out_img, kernel_size=4, stride=2, padding=1),
nn.LeakyReLU(0.2),
nn.Conv2d(out_img, out_img*2, kernel_size=4, stride=2, padding=1),
nn.BatchNorm2d(out_img*2),
nn.LeakyReLU(0.2),
nn.Conv2d(out_img*2, out_img*4, kernel_size=4, stride=2, padding=1),
nn.BatchNorm2d(out_img*4),
nn.LeakyReLU(0.2),
nn.Conv2d(out_img*4, out_img*8, kernel_size=4, stride=2, padding=1),
nn.BatchNorm2d(out_img*8),
nn.LeakyReLU(0.2),
nn.Conv2d(out_img*8, 1, kernel_size=4, stride=2, padding=0),
nn.Sigmoid()
)
def forward(self, x):
return self.conv(x)