fix models

This commit is contained in:
Filippo Olivo
2025-10-29 16:48:23 +01:00
parent 35770ace67
commit 5c5483744c
2 changed files with 32 additions and 26 deletions

View File

@@ -1,7 +1,6 @@
import torch
import torch.nn as nn
from torch_geometric.nn import MessagePassing
from tqdm import tqdm
class FiniteDifferenceStep(MessagePassing):
@@ -14,8 +13,9 @@ class FiniteDifferenceStep(MessagePassing):
assert (
aggr == "add"
), "Per somme pesate, l'aggregazione deve essere 'add'."
self.root_weight = float(root_weight)
self.p = torch.nn.Parameter(torch.tensor(0.5))
# self.root_weight = float(root_weight)
self.p = torch.nn.Parameter(torch.tensor(0.8))
self.a = root_weight
def forward(self, x, edge_index, edge_attr, deg):
"""
@@ -43,7 +43,9 @@ class FiniteDifferenceStep(MessagePassing):
"""
TODO: add docstring.
"""
return self.root_weight * aggr_out + (1 - self.root_weight) * x
a = torch.clamp(self.a, 0.0, 1.0)
return a * aggr_out + (1 - a) * x
# return self.a * aggr_out + (1 - self.a) * x
class GraphFiniteDifference(nn.Module):