File size: 1,173 Bytes
81484f1
2f32d1f
81484f1
 
 
 
2f32d1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81484f1
 
2f32d1f
81484f1
86b180a
 
2376ea4
cf81d06
 
 
2f32d1f
86b180a
 
2376ea4
 
 
e133eb4
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
import torch.nn as nn
import torch

class TumorClassification(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = nn.Sequential(
            nn.Conv2d(1, 32, 3, 1, 1),  # con1d
            nn.ReLU(),
            nn.MaxPool2d(2),
            nn.Conv2d(32, 64, 3, 1, 1), # con2d
            nn.ReLU(),
            nn.MaxPool2d(2),
            nn.Conv2d(64, 128, 3, 1, 1),# con3d
            nn.ReLU(),
            nn.MaxPool2d(2),
            nn.Flatten(),
            nn.Linear(128 * 26 * 26, 512),  # fc1
            nn.ReLU(),
            nn.Linear(512, 256),            # fc2
            nn.ReLU(),
            nn.Linear(256, 4)               # output
        )

    def forward(self, x):
        return self.model(x)

class GliomaStageModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(9, 100)
        self.fc2 = nn.Linear(100, 50)
        self.fc3 = nn.Linear(50, 30)
        self.out = nn.Linear(30, 2)

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