|
class SeizureDetectionCNN(nn.Module): |
|
def init(self, num_classes=2): |
|
super(SeizureDetectionCNN, self).init() |
|
self.conv1= nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1) |
|
|
|
self.pool= nn.MaxPool2d(kernel_size=2, stride=2) |
|
|
|
self.conv2= nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1) |
|
|
|
|
|
self.bn1 = nn.BatchNorm2d(32) |
|
self.bn2 = nn.BatchNorm2d(64) |
|
|
|
self.dropout = nn.Dropout(p=0.5) |
|
|
|
self.fc1= nn.Linear(64 * 8 * 8, 120) |
|
self.fc2= nn.Linear(120, 32) |
|
self.fc3= nn.Linear(32, num_classes) |
|
|
|
def forward(self, x): |
|
x = self.pool(F.relu(self.bn1(self.conv1(x)))) |
|
x = self.pool(F.relu(self.bn2(self.conv2(x)))) |
|
|
|
x = torch.flatten(x, 1) |
|
x = self.dropout(F.relu(self.fc1(x))) |
|
x = self.dropout(F.relu(self.fc2(x))) |
|
x = self.fc3(x) |
|
return x |
|
|