aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Halle <niklas@niklashalle.net>2021-09-20 14:01:54 +0200
committerNiklas Halle <niklas@niklashalle.net>2021-09-20 14:01:54 +0200
commitfff552d4c105c1659cc8acddce645f69214a568b (patch)
tree98b2170bcc33b0336ed5cd777b4309833e0eaa99
parentd8075571a161ff3cd01bc448837a71e7fe310e80 (diff)
downloadbachelor_thesis-main.tar.gz
bachelor_thesis-main.zip
trying to get it training WITH something like resultsmain
-rw-r--r--code/python/model.py19
-rwxr-xr-xcode/python/run.py4
2 files changed, 10 insertions, 13 deletions
diff --git a/code/python/model.py b/code/python/model.py
index e98d9d3..2076a35 100644
--- a/code/python/model.py
+++ b/code/python/model.py
@@ -3,19 +3,16 @@ import torch.nn.functional as F
class MLP(torch.nn.Module):
- def __init__(self, model_size, max_n_nodes, dropout):
+ def __init__(self, model_size, max_n_nodes):
super(MLP, self).__init__()
-# self.dropout = dropout
- self.linear1 = torch.nn.Linear(model_size, max_n_nodes*4)
-# self.linear2 = torch.nn.Linear(model_size, model_size)
- self.linear3 = torch.nn.Linear(max_n_nodes*2, max_n_nodes)
+ self.linear1 = torch.nn.Linear(model_size, 10000)
+ self.linear2 = torch.nn.Linear(10000, max_n_nodes)
+ self.linear3 = torch.nn.Linear(max_n_nodes, max_n_nodes)
def forward(self, input_vec):
score_temp = torch.flatten(input_vec)
- score_temp = F.relu(self.linear1(score_temp))
-# score_temp = F.dropout(score_temp, self.dropout)
-# score_temp = F.relu(self.linear2(score_temp))
-# score_temp = F.dropout(score_temp, self.dropout)
- result = self.linear3(score_temp)
+ score_temp = self.linear1(score_temp)
+ score_temp = F.relu(self.linear2(score_temp))
+ score_temp = self.linear3(score_temp)
- return result
+ return score_temp
diff --git a/code/python/run.py b/code/python/run.py
index 8d5e0f1..3e87ef3 100755
--- a/code/python/run.py
+++ b/code/python/run.py
@@ -64,7 +64,7 @@ def main(model_type="betweenness"):
print(f"preparing model ({model_size})")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# device = "cpu"
- model = MLP(model_size=model_size, max_n_nodes=max_nodes, dropout=0.6)
+ model = MLP(model_size=model_size, max_n_nodes=max_nodes)
model.to(device)
print(f"done (device: {device})")
@@ -108,7 +108,7 @@ def main(model_type="betweenness"):
with Timer() as t:
for e in range(num_epoch):
print(f"Epoch number: {e + 1}/{num_epoch}")
- train(model, device, optimizer, X_train, list_num_node_train, y_train, max_number_of_nodes)
+ train(model, device, optimizer, X_train, list_num_node_train, y_train, max_nodes)
# check test loss
with torch.no_grad():