-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconv.py
More file actions
54 lines (43 loc) · 1.43 KB
/
conv.py
File metadata and controls
54 lines (43 loc) · 1.43 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
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 7 14:03:03 2020
@author: rajiv
"""
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
class conv1(nn.Module):
def __init__(self):
super(conv1, self).__init__()
self.conv = nn.Conv2d(in_channels = 1, out_channels = 4, kernel_size = (5,5), stride=1, padding = 2, bias=False)
def forward(self, x):
out = self.conv(x)
return out
class pool1(nn.Module):
def __init__(self):
super(pool1, self).__init__()
def forward(self, x):
out = F.max_pool2d(x, kernel_size = 7, stride = 6)
return out
class conv2(nn.Module):
def __init__(self):
super(conv2, self).__init__()
self.conv = nn.Conv2d(in_channels = 4, out_channels = 20, kernel_size = (17, 17), stride = 1, padding = 2, bias = False)
def forward(self, x):
out = self.conv(x)
return out
class pool2(nn.Module):
def __init__(self):
super(pool2, self).__init__()
def forward(self,x):
out = F.max_pool2d(x, kernel_size = 5, stride = 5)
return out
class conv3(nn.Module):
def __init__(self):
super(conv3, self).__init__()
self.conv = nn.Conv2d(in_channels = 20, out_channels = 20, kernel_size =(5, 5), stride= 1, padding = 0, bias = False)
def forward(self, x):
out = self.conv(x)
return out