-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
47 lines (32 loc) · 1.18 KB
/
Copy pathgenerator.py
File metadata and controls
47 lines (32 loc) · 1.18 KB
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
# -*- coding: utf-8 -*-
import torch
import torchvision
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
import json
import os
import io
from torch import nn
NUM_CLASSES = 2
class Generator(nn.Module):
def __init__(self):
super(Generator, self).__init__()
self.conv1 = nn.Conv2d(in_channels=1, out_channels=32, kernel_size=3)
self.conv2 = nn.Conv2d(in_channels=32, out_channels=64, kernel_size=3)
self.dconv1 = nn.ConvTranspose2d(in_channels=64, out_channels=32, kernel_size=3)
self.dconv2 = nn.ConvTranspose2d(in_channels=32, out_channels=NUM_CLASSES, kernel_size=3)
self.softmax = nn.Softmax(dim=1)
def forward(self, x):
activation = F.relu
x = self.conv1(x)
x = activation(x)
x = self.conv2(x)
x = activation(x)
x = self.dconv1(x)
x = activation(x)
x = self.dconv2(x)
x = activation(x)
x = self.softmax(x)
return x