class_docstr: The graph convolutional operator with initial residual connections and
  identity mapping (GCNII) from the `"Simple and Deep Graph Convolutional
  Networks" <https://arxiv.org/abs/2007.02133>`_ paper.
  
  .. math::
      \mathbf{X}^{\prime} = \left( (1 - \alpha) \mathbf{\hat{P}}\mathbf{X} +
      \alpha \mathbf{X^{(0)}}\right) \left( (1 - \beta) \mathbf{I} + \beta
      \mathbf{\Theta} \right)
  
  with :math:`\mathbf{\hat{P}} = \mathbf{\hat{D}}^{-1/2} \mathbf{\hat{A}}
  \mathbf{\hat{D}}^{-1/2}`, where
  :math:`\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}` denotes the adjacency
  matrix with inserted self-loops and
  :math:`\hat{D}_{ii} = \sum_{j=0} \hat{A}_{ij}` its diagonal degree matrix,
  and :math:`\mathbf{X}^{(0)}` being the initial feature representation.
  Here, :math:`\alpha` models the strength of the initial residual
  connection, while :math:`\beta` models the strength of the identity
  mapping.
  The adjacency matrix can include other values than :obj:`1` representing
  edge weights via the optional :obj:`edge_weight` tensor.
  
  Args:
      channels (int): Size of each input and output sample.
      alpha (float): The strength of the initial residual connection
          :math:`\alpha`.
      theta (float, optional): The hyperparameter :math:`\theta` to compute
          the strength of the identity mapping
          :math:`\beta = \log \left( \frac{\theta}{\ell} + 1 \right)`.
          (default: :obj:`None`)
      layer (int, optional): The layer :math:`\ell` in which this module is
          executed. (default: :obj:`None`)
      shared_weights (bool, optional): If set to :obj:`False`, will use
          different weight matrices for the smoothed representation and the
          initial residual ("GCNII*"). (default: :obj:`True`)
      cached (bool, optional): If set to :obj:`True`, the layer will cache
          the computation of :math:`\mathbf{\hat{D}}^{-1/2} \mathbf{\hat{A}}
          \mathbf{\hat{D}}^{-1/2}` on first execution, and will use the
          cached version for further executions.
          This parameter should only be set to :obj:`True` in transductive
          learning scenarios. (default: :obj:`False`)
      normalize (bool, optional): Whether to add self-loops and apply
          symmetric normalization. (default: :obj:`True`)
      add_self_loops (bool, optional): If set to :obj:`False`, will not add
          self-loops to the input graph. (default: :obj:`True`)
      **kwargs (optional): Additional arguments of
          :class:`torch_geometric.nn.conv.MessagePassing`.
  
  Shapes:
      - **input:**
        node features :math:`(|\mathcal{V}|, F)`,
        initial node features :math:`(|\mathcal{V}|, F)`,
        edge indices :math:`(2, |\mathcal{E}|)`,
        edge weights :math:`(|\mathcal{E}|)` *(optional)*
      - **output:** node features :math:`(|\mathcal{V}|, F)`
class_docstr_tok: ["The","graph","convolutional","operator","with","initial","residual","connections","and","identity","mapping","(","GCNII",")","from","the","`","``","Simple","and","Deep","Graph","Convolutional","Networks","''","<","https",":","\/\/arxiv.org\/abs\/2007.02133",">","`","_","paper",".","..","math",":",":","\\mathbf","{","X","}","^","{","\\prime","}","=","\\left","(","(","1","-","\\alpha",")","\\mathbf","{","\\hat","{","P","}","}","\\mathbf","{","X","}","+","\\alpha","\\mathbf","{","X^","{","(","0",")","}","}","\\right",")","\\left","(","(","1","-","\\beta",")","\\mathbf","{","I","}","+","\\beta","\\mathbf","{","\\Theta","}","\\right",")","with",":","math",":","`","\\mathbf","{","\\hat","{","P","}","}","=","\\mathbf","{","\\hat","{","D","}","}","^","{","-1\/2","}","\\mathbf","{","\\hat","{","A","}","}","\\mathbf","{","\\hat","{","D","}","}","^","{","-1\/2","}","`",",","where",":","math",":","`","\\mathbf","{","\\hat","{","A","}","}","=","\\mathbf","{","A","}","+","\\mathbf","{","I","}","`","denotes","the","adjacency","matrix","with","inserted","self-loops","and",":","math",":","`","\\hat","{","D","}","_","{","ii","}","=","\\sum_","{","j=0","}","\\hat","{","A","}","_","{","ij","}","`","its","diagonal","degree","matrix",",","and",":","math",":","`","\\mathbf","{","X","}","^","{","(","0",")","}","`","being","the","initial","feature","representation",".","Here",",",":","math",":","`","\\alpha","`","models","the","strength","of","the","initial","residual","connection",",","while",":","math",":","`","\\beta","`","models","the","strength","of","the","identity","mapping",".","The","adjacency","matrix","can","include","other","values","than",":","obj",":","`","1","`","representing","edge","weights","via","the","optional",":","obj",":","`","edge_weight","`","tensor",".","Args",":","channels","(","int",")",":","Size","of","each","input","and","output","sample",".","alpha","(","float",")",":","The","strength","of","the","initial","residual","connection",":","math",":","`","\\alpha","`",".","theta","(","float",",","optional",")",":","The","hyperparameter",":","math",":","`","\\theta","`","to","compute","the","strength","of","the","identity","mapping",":","math",":","`","\\beta","=","\\log","\\left","(","\\frac","{","\\theta","}","{","\\ell","}","+","1","\\right",")","`",".","(","default",":",":","obj",":","`","None","`",")","layer","(","int",",","optional",")",":","The","layer",":","math",":","`","\\ell","`","in","which","this","module","is","executed",".","(","default",":",":","obj",":","`","None","`",")","shared_weights","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","False","`",",","will","use","different","weight","matrices","for","the","smoothed","representation","and","the","initial","residual","(","``","GCNII","*","''",")",".","(","default",":",":","obj",":","`","True","`",")","cached","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","True","`",",","the","layer","will","cache","the","computation","of",":","math",":","`","\\mathbf","{","\\hat","{","D","}","}","^","{","-1\/2","}","\\mathbf","{","\\hat","{","A","}","}","\\mathbf","{","\\hat","{","D","}","}","^","{","-1\/2","}","`","on","first","execution",",","and","will","use","the","cached","version","for","further","executions",".","This","parameter","should","only","be","set","to",":","obj",":","`","True","`","in","transductive","learning","scenarios",".","(","default",":",":","obj",":","`","False","`",")","normalize","(","bool",",","optional",")",":","Whether","to","add","self-loops","and","apply","symmetric","normalization",".","(","default",":",":","obj",":","`","True","`",")","add_self_loops","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","False","`",",","will","not","add","self-loops","to","the","input","graph",".","(","default",":",":","obj",":","`","True","`",")","*","*","kwargs","(","optional",")",":","Additional","arguments","of",":","class",":","`","torch_geometric.nn.conv.MessagePassing","`",".","Shapes",":","-","*","*","input",":","*","*","node","features",":","math",":","`","(","|\\mathcal","{","V","}","|",",","F",")","`",",","initial","node","features",":","math",":","`","(","|\\mathcal","{","V","}","|",",","F",")","`",",","edge","indices",":","math",":","`","(","2",",","|\\mathcal","{","E","}","|",")","`",",","edge","weights",":","math",":","`","(","|\\mathcal","{","E","}","|",")","`","*","(","optional",")","*","-","*","*","output",":","*","*","node","features",":","math",":","`","(","|\\mathcal","{","V","}","|",",","F",")","`"]
code: def __init__(
      self,
      channels: int,
      alpha: float,
      theta: float = None,
      layer: int = None,
      shared_weights: bool = True,
      cached: bool = False,
      add_self_loops: bool = True,
      normalize: bool = True,
      **kwargs,
  ):
      kwargs.setdefault("aggr", "add")
      super().__init__(**kwargs)
  
      self.channels = channels
      self.alpha = alpha
      self.beta = 1.0
      if theta is not None or layer is not None:
          assert theta is not None and layer is not None
          self.beta = log(theta / layer + 1)
      self.cached = cached
      self.normalize = normalize
      self.add_self_loops = add_self_loops
  
      self._cached_edge_index = None
      self._cached_adj_t = None
  
      self.weight1 = Parameter(torch.empty(channels, channels))
  
      if shared_weights:
          self.register_parameter("weight2", None)
      else:
          self.weight2 = Parameter(torch.empty(channels, channels))
  
      self.reset_parameters()
  
file_path: pytorch_geometric/torch_geometric/nn/conv/gcn2_conv.py
imports: from math import log
  from typing import Optional
  import torch
  from torch import Tensor
  from torch.nn import Parameter
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.nn.conv.gcn_conv import gcn_norm
  from torch_geometric.nn.inits import glorot
  from torch_geometric.typing import Adj, OptPairTensor, OptTensor, SparseTensor
  from torch_geometric.utils import spmm
label_desc: Use image node_id 1 to create a new GCN2Conv object from inherited base classes: MessagePassing with example: obj = GCN2Conv(channels, alpha, theta, layer, shared_weights, cached, add__loops, normalize)