# -*- coding: utf-8 -*-"""Convolutional Layers for Graph Neural Networks."""# Author: Kay Liu <zliu234@uic.edu># License: BSD 2 clauseimporttorchfromtorch_geometric.nnimportMessagePassingfromtorch_geometric.utilsimportsoftmax,add_self_loops
[docs]classNeighDiff(MessagePassing):""" Calculate the Euclidean distance between the node features of the central node and its neighbors, reducing by mean. """def__init__(self):super().__init__(aggr='mean')
[docs]classGNAConv(MessagePassing):""" Graph Node Attention Network (GNA) layer. See :cite:`yuan2021higher` for more details. """def__init__(self,in_channels,out_channels):super().__init__(aggr='add')self.w1=torch.nn.Linear(in_channels,out_channels)self.w2=torch.nn.Linear(in_channels,out_channels)self.a=torch.nn.Parameter(torch.randn(out_channels,1))