From cd5cbed17994ec9f1ae41be139d49bc795c2b7d4 Mon Sep 17 00:00:00 2001 From: mzaninovic Date: Tue, 7 May 2024 18:43:43 +0200 Subject: [PATCH] gitignore, model changes, epoch number changes --- .gitignore | 2 +- model/football_dataset.py | 10 ++-------- model/neural_network.py | 11 ++++------- model/train.py | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 43d49c3..65b558b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 models/** -runs/** +model/** .idea/** diff --git a/model/football_dataset.py b/model/football_dataset.py index 1a36950..ec3c296 100644 --- a/model/football_dataset.py +++ b/model/football_dataset.py @@ -20,13 +20,6 @@ def __init__(self, csv_file): "competition_type"], inplace=True) self.data.dropna(inplace=True) - # self.data.fillna(0, inplace=True) - - # transform all except result columns - x_scaled = preprocessing.MinMaxScaler().fit_transform(self.data) - - # concat scaled and result columns - self.data = pd.DataFrame(x_scaled) def __len__(self): return len(self.data) @@ -36,4 +29,5 @@ def __getitem__(self, idx): features = sample[:-3].values.astype(dtype=float) target = sample[-3:].values.astype(dtype=float) - return torch.tensor(features, dtype=torch.float32), torch.tensor(target, dtype=torch.float32) + return (torch.tensor(features, dtype=torch.float32), + torch.tensor(target, dtype=torch.float32)) diff --git a/model/neural_network.py b/model/neural_network.py index b1a4f96..0524836 100644 --- a/model/neural_network.py +++ b/model/neural_network.py @@ -4,10 +4,10 @@ input_features = 20 output_features = 3 -dropout_rate = 0.5 -hidden_layer_size = floor(input_features * 16) -hidden_layer_size2 = floor(input_features * 8) -hidden_layer_size3 = floor(input_features * 4) +dropout_rate = 0.2 +hidden_layer_size = floor(input_features * 2) +hidden_layer_size2 = floor(input_features * 2) +hidden_layer_size3 = floor(input_features * 2) hidden_layer_size4 = floor(input_features * 2) @@ -26,19 +26,16 @@ def __init__(self): # hidden 1 nn.Linear(hidden_layer_size, hidden_layer_size2), - nn.BatchNorm1d(hidden_layer_size2), self.activation_function, self.dropout, # hidden 2 nn.Linear(hidden_layer_size2, hidden_layer_size3), - nn.BatchNorm1d(hidden_layer_size3), self.activation_function, self.dropout, # hidden 3 nn.Linear(hidden_layer_size3, hidden_layer_size4), - nn.BatchNorm1d(hidden_layer_size4), self.activation_function, # output diff --git a/model/train.py b/model/train.py index dd1a4c7..125e744 100644 --- a/model/train.py +++ b/model/train.py @@ -14,7 +14,7 @@ dataset = FootballDataset('./data/dataset.csv') batch_size = 64 -epochs = 80 +epochs = 30 learning_rate = 0.003 device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') @@ -85,7 +85,7 @@ now = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S') model_scripted = torch.jit.script(model) -model_scripted.save(f'./models/football_predictor_{now}_dict.pt') +model_scripted.save(f'./models/football_predictor_{now}.pt') # torch.save(model.state_dict(), f'./models/football_predictor_{now}_dict.pt') # torch.save(model, f'./models/football_predictor_{now}_model.pt')