Skip to content

Commit 334c043

Browse files
committed
add new strategy to choose best models
1 parent deccc47 commit 334c043

8 files changed

+580
-1329
lines changed

code/GCN.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
from torch_geometric.nn import (
55
GCNConv,
66
GATConv,
7+
GATv2Conv,
78
global_max_pool,
89
global_mean_pool,
910
global_add_pool,
1011
GraphNorm,
1112
)
1213
from torch_geometric.utils import dense_to_sparse
1314
from torch.optim.lr_scheduler import StepLR
14-
from tqdm import tqdm
15+
from tqdm.notebook import tqdm
1516
import matplotlib.pyplot as plt
1617
import numpy as np
1718
from torch.utils.data import Dataset
@@ -144,10 +145,10 @@ def __init__(self, input_dim, output_dim=16, dropout=0.5, pooling="max", heads=4
144145
self.heads = heads
145146

146147
# Attention Conv слои
147-
self.gat1 = GATConv(input_dim, self.hidden_dim // heads, heads=heads)
148-
self.gat2 = GATConv(self.hidden_dim, 256 // heads, heads=heads)
149-
self.gat3 = GATConv(256, 256 // heads, heads=heads)
150-
self.gat4 = GATConv(256, self.hidden_dim // heads, heads=heads)
148+
self.gat1 = GATv2Conv(input_dim, self.hidden_dim // heads, heads=heads)
149+
self.gat2 = GATv2Conv(self.hidden_dim, 256 // heads, heads=heads)
150+
self.gat3 = GATv2Conv(256, 256 // heads, heads=heads)
151+
self.gat4 = GATv2Conv(256, self.hidden_dim // heads, heads=heads)
151152

152153
# Проекции для full residual
153154
self.res1 = nn.Linear(input_dim, self.hidden_dim)
@@ -522,8 +523,8 @@ def train_model_accuracy(
522523
plt.show()
523524

524525
lr = scheduler.get_last_lr()[0]
525-
print(f"Epoch {epoch+1}, Train Loss: {avg_train_loss:.4f}, "
526-
f"Valid Loss: {avg_valid_loss:.4f}, LR: {lr:.6f}")
526+
print(f"Epoch {epoch+1}, Train Loss: {avg_train_loss * 1e4:.4f}, "
527+
f"Valid Loss: {avg_valid_loss * 1e4:.4f}, LR: {lr:.6f}")
527528

528529
return train_losses, valid_losses
529530

code/dependecies.zip

33 Bytes
Binary file not shown.

code/gcn-training.ipynb

Lines changed: 571 additions & 980 deletions
Large diffs are not rendered by default.

code/greedy-finding-best-models.ipynb

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

code/greedy_finding_best_models.ipynb

Lines changed: 0 additions & 342 deletions
This file was deleted.

code/weights.zip

2.2 MB
Binary file not shown.
476 KB
Binary file not shown.
504 KB
Binary file not shown.

0 commit comments

Comments
 (0)