petter2025 commited on
Commit
4d2e5b5
·
verified ·
1 Parent(s): f4dfe34

Delete gnn_predictor.py

Browse files
Files changed (1) hide show
  1. gnn_predictor.py +0 -40
gnn_predictor.py DELETED
@@ -1,40 +0,0 @@
1
- """
2
- PyTorch Geometric model for failure propagation prediction.
3
- Falls back to dummy linear model if PyG not available.
4
- """
5
- import torch
6
- import torch.nn.functional as F
7
-
8
- try:
9
- from torch_geometric.nn import GCNConv
10
- TORCH_GEOMETRIC_AVAILABLE = True
11
- except ImportError:
12
- TORCH_GEOMETRIC_AVAILABLE = False
13
-
14
- class FailureGNN(torch.nn.Module):
15
- def __init__(self, num_features=5, hidden=16, num_classes=2):
16
- super().__init__()
17
- self.num_features = num_features
18
- self.hidden = hidden
19
- self.num_classes = num_classes
20
-
21
- if TORCH_GEOMETRIC_AVAILABLE:
22
- self.conv1 = GCNConv(num_features, hidden)
23
- self.conv2 = GCNConv(hidden, num_classes)
24
- else:
25
- # Fallback linear model (no graph structure)
26
- self.fc = torch.nn.Linear(num_features, num_classes)
27
-
28
- def forward(self, x, edge_index=None):
29
- """
30
- x: node features [num_nodes, num_features]
31
- edge_index: graph connectivity [2, num_edges] (optional)
32
- """
33
- if TORCH_GEOMETRIC_AVAILABLE and edge_index is not None:
34
- x = self.conv1(x, edge_index)
35
- x = F.relu(x)
36
- x = F.dropout(x, training=self.training)
37
- x = self.conv2(x, edge_index)
38
- else:
39
- x = self.fc(x) # ignore graph structure
40
- return F.log_softmax(x, dim=1)