ArxAlfa commited on
Commit
7b1ff82
1 Parent(s): c0ad13a

Update DNN architecture and KFold split

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -17,18 +17,22 @@ class DNN(nn.Module):
17
  def __init__(self, input_size, hidden_size, output_size):
18
  super(DNN, self).__init__()
19
  self.fc1 = nn.Linear(input_size, hidden_size)
20
- self.relu = nn.ReLU()
21
- self.fc2 = nn.Linear(hidden_size, output_size)
 
 
22
 
23
  def forward(self, x):
24
  x = self.fc1(x)
25
- x = self.relu(x)
26
  x = self.fc2(x)
 
 
27
  return x
28
 
29
 
30
  # Load the model
31
- model = DNN(input_size=7, hidden_size=128, output_size=1)
32
 
33
  # Initialize the OneHotEncoder
34
  encoder = OneHotEncoder(handle_unknown="ignore")
@@ -90,7 +94,7 @@ async def train(file: UploadFile = File(...)):
90
  optimizer = optim.Adam(model.parameters(), lr=0.0001)
91
 
92
  # Fit the model
93
- kf = KFold(n_splits=4)
94
  accuracies = []
95
 
96
  epochs = 50 # Define the number of epochs
 
17
  def __init__(self, input_size, hidden_size, output_size):
18
  super(DNN, self).__init__()
19
  self.fc1 = nn.Linear(input_size, hidden_size)
20
+ self.relu1 = nn.ReLU()
21
+ self.fc2 = nn.Linear(hidden_size, hidden_size)
22
+ self.relu2 = nn.ReLU()
23
+ self.fc3 = nn.Linear(hidden_size, output_size)
24
 
25
  def forward(self, x):
26
  x = self.fc1(x)
27
+ x = self.relu1(x)
28
  x = self.fc2(x)
29
+ x = self.relu2(x)
30
+ x = self.fc3(x)
31
  return x
32
 
33
 
34
  # Load the model
35
+ model = DNN(input_size=7, hidden_size=256, output_size=1)
36
 
37
  # Initialize the OneHotEncoder
38
  encoder = OneHotEncoder(handle_unknown="ignore")
 
94
  optimizer = optim.Adam(model.parameters(), lr=0.0001)
95
 
96
  # Fit the model
97
+ kf = KFold(n_splits=5)
98
  accuracies = []
99
 
100
  epochs = 50 # Define the number of epochs