File size: 1,280 Bytes
ef4db92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch.nn as nn
import torch.nn.functional as F

# Tumor Classification CNN
class TumorClassification(nn.Module):
    def __init__(self):
        super(TumorClassification, self).__init__()
        self.con1d = nn.Conv2d(1, 32, kernel_size=3, padding=1)
        self.con2d = nn.Conv2d(32, 64, kernel_size=3, padding=1)
        self.con3d = nn.Conv2d(64, 128, kernel_size=3, padding=1)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc1 = nn.Linear(128 * 29 * 29, 512)
        self.fc2 = nn.Linear(512, 256)
        self.output = nn.Linear(256, 4)

    def forward(self, x):
        x = self.pool(F.relu(self.con1d(x)))
        x = self.pool(F.relu(self.con2d(x)))
        x = self.pool(F.relu(self.con3d(x)))
        x = x.view(x.size(0), -1)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        return self.output(x)

# Glioma Stage Predictor
class GliomaStageModel(nn.Module):
    def __init__(self):
        super(GliomaStageModel, self).__init__()
        self.fc1 = nn.Linear(9, 100)
        self.fc2 = nn.Linear(100, 50)
        self.fc3 = nn.Linear(50, 30)
        self.out = nn.Linear(30, 4)

    def forward(self, x):
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = F.relu(self.fc3(x))
        return self.out(x)