Advertisement
EXTREMEXPLOIT

90% Accuracy Model

May 27th, 2022
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. # ResNet style network
  2. class MyModel(nn.Module):
  3.     def __init__(self, outputNeurons=10):
  4.         super(MyModel, self).__init__()
  5.        
  6.         self.conv1 = nn.Conv2d(1, 16, kernel_size=8,  padding=2)
  7.         # Input : 1 Channel, Output 16 Channel, Filter Size : 8x8
  8.  
  9.         self.conv2 = nn.Conv2d(16, 32, kernel_size=5,  padding=1)
  10.         # Input : 1 Channel, Output 16 Channel, Filter Size : 5x5
  11.  
  12.         self.conv3 = nn.Conv2d(32, 64, kernel_size=3,  padding=1)
  13.         # Input : 1 Channel, Output 64 Channel, Filter Size : 3x3
  14.  
  15.         self.conv4 = nn.Conv2d(64, 128, kernel_size=3,  padding=1)
  16.         # Input : 1 Channel, Output 64 Channel, Filter Size : 3x3
  17.        
  18.         self.fc = nn.Linear(128, outputNeurons)
  19.         self.maxpool= nn.MaxPool2d(kernel_size=2, stride=2)
  20.         self.relu = nn.ReLU()
  21.        
  22.     def forward(self, x):
  23.         out = self.conv1(x)
  24.         out = self.relu(out)
  25.         out = self.maxpool(out)
  26.        
  27.         out = self.conv2(out)
  28.         out = self.relu(out)
  29.         out = self.maxpool(out)
  30.  
  31.         out = self.conv3(out)
  32.         out = self.relu(out)
  33.         out = self.maxpool(out)
  34.  
  35.         out = self.conv4(out)
  36.         out = self.relu(out)
  37.         out = self.maxpool(out)
  38.        
  39.         out = out.reshape(out.size(0), -1)
  40.         out = self.fc(out)
  41.        
  42.         return out
  43.  
  44.     def __len__(self):
  45.         return sum([x.numel() for x in self.parameters()])
  46.  
  47. testInstance = MyModel()
  48.  
  49. if len(testInstance) > 150000:
  50.     print(f"Invalid Network, {len(testInstance)} Parameters!")
  51. else:
  52.     print(f"Valid Network, {len(testInstance)} Parameters!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement