Codewithsalty commited on
Commit
2f32d1f
·
verified ·
1 Parent(s): 91d7910

Update TumorModel.py

Browse files
Files changed (1) hide show
  1. 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.con1d = nn.Conv2d(1, 32, kernel_size=3, padding=1)
7
- self.con2d = nn.Conv2d(32, 64, kernel_size=3, padding=1)
8
- self.con3d = nn.Conv2d(64, 128, kernel_size=3, padding=1)
9
- self.pool = nn.MaxPool2d(2, 2)
10
- self.fc1 = nn.Linear(128 * 28 * 28, 512)
11
- self.fc2 = nn.Linear(512, 256)
12
- self.output = nn.Linear(256, 4)
 
 
 
 
 
 
 
 
 
 
13
 
14
  def forward(self, x):
15
- x = nn.functional.relu(self.pool(self.con1d(x)))
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) # ✅ Make sure this matches your trained model
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))