Spaces:
Runtime error
Runtime error
Update TumorModel.py
Browse files- TumorModel.py +20 -15
TumorModel.py
CHANGED
@@ -1,24 +1,29 @@
|
|
1 |
import torch.nn as nn
|
|
|
2 |
|
3 |
class TumorClassification(nn.Module):
|
4 |
def __init__(self):
|
5 |
super().__init__()
|
6 |
-
self.
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def forward(self, x):
|
15 |
-
|
16 |
-
x = nn.functional.relu(self.pool(self.con2d(x)))
|
17 |
-
x = nn.functional.relu(self.pool(self.con3d(x)))
|
18 |
-
x = x.view(x.size(0), -1)
|
19 |
-
x = nn.functional.relu(self.fc1(x))
|
20 |
-
x = nn.functional.relu(self.fc2(x))
|
21 |
-
return self.output(x)
|
22 |
|
23 |
class GliomaStageModel(nn.Module):
|
24 |
def __init__(self):
|
@@ -26,7 +31,7 @@ class GliomaStageModel(nn.Module):
|
|
26 |
self.fc1 = nn.Linear(9, 100)
|
27 |
self.fc2 = nn.Linear(100, 50)
|
28 |
self.fc3 = nn.Linear(50, 30)
|
29 |
-
self.out = nn.Linear(30, 2)
|
30 |
|
31 |
def forward(self, x):
|
32 |
x = nn.functional.relu(self.fc1(x))
|
|
|
1 |
import torch.nn as nn
|
2 |
+
import torch
|
3 |
|
4 |
class TumorClassification(nn.Module):
|
5 |
def __init__(self):
|
6 |
super().__init__()
|
7 |
+
self.model = nn.Sequential(
|
8 |
+
nn.Conv2d(1, 32, 3, 1, 1), # con1d
|
9 |
+
nn.ReLU(),
|
10 |
+
nn.MaxPool2d(2),
|
11 |
+
nn.Conv2d(32, 64, 3, 1, 1), # con2d
|
12 |
+
nn.ReLU(),
|
13 |
+
nn.MaxPool2d(2),
|
14 |
+
nn.Conv2d(64, 128, 3, 1, 1),# con3d
|
15 |
+
nn.ReLU(),
|
16 |
+
nn.MaxPool2d(2),
|
17 |
+
nn.Flatten(),
|
18 |
+
nn.Linear(128 * 26 * 26, 512), # fc1
|
19 |
+
nn.ReLU(),
|
20 |
+
nn.Linear(512, 256), # fc2
|
21 |
+
nn.ReLU(),
|
22 |
+
nn.Linear(256, 4) # output
|
23 |
+
)
|
24 |
|
25 |
def forward(self, x):
|
26 |
+
return self.model(x)
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
class GliomaStageModel(nn.Module):
|
29 |
def __init__(self):
|
|
|
31 |
self.fc1 = nn.Linear(9, 100)
|
32 |
self.fc2 = nn.Linear(100, 50)
|
33 |
self.fc3 = nn.Linear(50, 30)
|
34 |
+
self.out = nn.Linear(30, 2)
|
35 |
|
36 |
def forward(self, x):
|
37 |
x = nn.functional.relu(self.fc1(x))
|