Codewithsalty commited on
Commit
e4d0007
·
verified ·
1 Parent(s): 64d242b

Update TumorModel.py

Browse files
Files changed (1) hide show
  1. TumorModel.py +47 -34
TumorModel.py CHANGED
@@ -1,34 +1,47 @@
1
- import torch.nn as nn
2
-
3
- class TumorClassification(nn.Module):
4
- def __init__(self):
5
- super().__init__()
6
- self.model = nn.Sequential(
7
- nn.Conv2d(1, 16, 3, 1, 1),
8
- nn.ReLU(),
9
- nn.MaxPool2d(2),
10
- nn.Conv2d(16, 32, 3, 1, 1),
11
- nn.ReLU(),
12
- nn.MaxPool2d(2),
13
- nn.Flatten(),
14
- nn.Linear(32 * 56 * 56, 128),
15
- nn.ReLU(),
16
- nn.Linear(128, 4)
17
- )
18
-
19
- def forward(self, x):
20
- return self.model(x)
21
-
22
- class GliomaStageModel(nn.Module):
23
- def __init__(self):
24
- super().__init__()
25
- self.model = nn.Sequential(
26
- nn.Linear(9, 128),
27
- nn.ReLU(),
28
- nn.Linear(128, 64),
29
- nn.ReLU(),
30
- nn.Linear(64, 4)
31
- )
32
-
33
- def forward(self, x):
34
- return self.model(x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TumorModel.py
2
+
3
+ import torch.nn as nn
4
+
5
+ class TumorClassification(nn.Module):
6
+ def __init__(self):
7
+ super(TumorClassification, self).__init__()
8
+ self.con1d = nn.Conv2d(1, 16, kernel_size=3, stride=1, padding=1)
9
+ self.relu1 = nn.ReLU()
10
+ self.pool1 = nn.MaxPool2d(2)
11
+
12
+ self.con2d = nn.Conv2d(16, 32, kernel_size=3, stride=1, padding=1)
13
+ self.relu2 = nn.ReLU()
14
+ self.pool2 = nn.MaxPool2d(2)
15
+
16
+ self.con3d = nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1)
17
+ self.relu3 = nn.ReLU()
18
+ self.pool3 = nn.MaxPool2d(2)
19
+
20
+ self.flatten = nn.Flatten()
21
+ self.fc1 = nn.Linear(64 * 28 * 28, 128) # Adjusted if input is (1, 224, 224)
22
+ self.relu_fc = nn.ReLU()
23
+ self.fc2 = nn.Linear(128, 4)
24
+
25
+ def forward(self, x):
26
+ x = self.pool1(self.relu1(self.con1d(x)))
27
+ x = self.pool2(self.relu2(self.con2d(x)))
28
+ x = self.pool3(self.relu3(self.con3d(x)))
29
+ x = self.flatten(x)
30
+ x = self.relu_fc(self.fc1(x))
31
+ x = self.fc2(x)
32
+ return x
33
+
34
+
35
+ class GliomaStageModel(nn.Module):
36
+ def __init__(self):
37
+ super().__init__()
38
+ self.model = nn.Sequential(
39
+ nn.Linear(9, 128),
40
+ nn.ReLU(),
41
+ nn.Linear(128, 64),
42
+ nn.ReLU(),
43
+ nn.Linear(64, 4)
44
+ )
45
+
46
+ def forward(self, x):
47
+ return self.model(x)