MCPcopy Create free account
hub / github.com/IgaoGuru/Sequoia / Light_Classifier

Class Light_Classifier

light_classifier.py:20–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18# import pandas as pd
19
20class Light_Classifier(torch.nn.Module):
21 def __init__(self):
22 super(Light_Classifier, self).__init__()
23 self.conv1 = self.conv_block(c_in = 3, c_out = 15, kernel_size = 3, stride = 1, padding = 1)
24 self.conv2 = self.conv_block(c_in = 15, c_out = 12, kernel_size = 3, stride = 1, padding = 1)
25 self.conv3 = self.conv_block(c_in = 12, c_out = 3, kernel_size = 3, stride = 1, padding = 1)
26 # 32px --> 48
27 # 100px --> 432
28 # self.bigN = 432
29 self.bigN = 48
30 self.fc1 = nn.Linear(self.bigN, 32)
31 self.fc2 = nn.Linear(32, 16)
32 self.fc3 = nn.Linear(16, 1)
33 self.maxpool = nn.MaxPool2d(kernel_size=2, stride=2)
34 # self.prefc1 = nn.Linear(self.bigN, )
35
36 def conv_block(self, c_in, c_out, dropout=0.1, kernel_size=3, stride=1, **kwargs):
37 seq_block = nn.Sequential(
38 nn.Conv2d(in_channels=c_in, out_channels=c_out, kernel_size=kernel_size, **kwargs),
39 nn.BatchNorm2d(num_features=c_out),
40 nn.ReLU(),
41 # nn.Dropout2d(p=dropout)
42 )
43 return seq_block
44
45 def forward(self, x):
46 x = self.conv1(x)
47 x = self.maxpool(x)
48
49 x = self.conv2(x)
50 x = self.maxpool(x)
51
52 x = self.conv3(x)
53 x = self.maxpool(x)
54 x = x.reshape((-1, self.bigN))
55
56 x = F.relu(self.fc1(x))
57 x = F.relu(self.fc2(x))
58 x = torch.sigmoid(self.fc3(x))
59 return x
60
61class Heavy_Classifier(torch.nn.Module):
62 def __init__(self):

Callers 3

findmeanstd.pyFile · 0.90
light_inference.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected