brain-tumor-predictor / TumorModel.py
Codewithsalty's picture
Update TumorModel.py
2f32d1f verified
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)