[docs]defforward(self,adj,feat,lambda_max=None):r"""Compute (Dense) Chebyshev Spectral Graph Convolution layer Parameters ---------- adj : torch.Tensor The adjacency matrix of the graph to apply Graph Convolution on, should be of shape :math:`(N, N)`, where a row represents the destination and a column represents the source. feat : torch.Tensor The input feature of shape :math:`(N, D_{in})` where :math:`D_{in}` is size of input feature, :math:`N` is the number of nodes. lambda_max : float or None, optional A float value indicates the largest eigenvalue of given graph. Default: None. Returns ------- torch.Tensor The output feature of shape :math:`(N, D_{out})` where :math:`D_{out}` is size of output feature. """A=adj.to(feat)num_nodes=A.shape[0]in_degree=1/A.sum(dim=1).clamp(min=1).sqrt()D_invsqrt=th.diag(in_degree)I=th.eye(num_nodes).to(A)L=I-D_invsqrt@A@D_invsqrtiflambda_maxisNone:lambda_=th.eig(L)[0][:,0]lambda_max=lambda_.max()L_hat=2*L/lambda_max-IZ=[th.eye(num_nodes).to(A)]foriinrange(1,self._k):ifi==1:Z.append(L_hat)else:Z.append(2*L_hat@Z[-1]-Z[-2])Zs=th.stack(Z,0)# (k, n, n)Zh=Zs@feat.unsqueeze(0)@self.WZh=Zh.sum(0)ifself.biasisnotNone:Zh=Zh+self.biasreturnZh