Belle II Software development
GATGAPModel Class Reference
Inheritance diagram for GATGAPModel:

Public Member Functions

def __init__ (self, units=128, num_features=8, num_pdg=NUM_PDG, emb_size=8, attention_heads=4, n_layers=5, use_gap=False)
 
def forward (self, graph)
 

Public Attributes

 pdg_embedding
 Embedding layer for PDG IDs.
 
 gat_layers
 List of GAT modules to update node features.
 
 fc_output
 Output layer for final prediction.
 

Detailed Description

Input:
   dgl graph built from decay event

Arguments:
   units(int): Number of units for the output dimension of GAT Convolutional layers
   as well as the dimension of global features
   num_features(int): Number of features attached to each node or particle as NN input
   num_pdg(int): Number of all possible PDG IDs
   emb_size(int): Dimension of embedded PDG space
   attention_heads(int): Number of attention heads for GAT Convolutional layers
   n_layers(int): Number of GAT Convolutional layers
   use_gap(bool): Whether to use Global Attention Pooling (GAP) for the production of global features

Returns:
   logits(float): Indicating the probability of an event being able to pass the
   corresponding skim, need `sigmoid` to be used as a prediction

Definition at line 88 of file gatgap.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  units = 128,
  num_features = 8,
  num_pdg = NUM_PDG,
  emb_size = 8,
  attention_heads = 4,
  n_layers = 5,
  use_gap = False 
)
Initialise the class.

:param units: Number of units for the output dimension of GAT Convolutional layers
as well as the dimension of global features.
:param num_features: Number of features attached to each node or particle as NN input.
:param num_pdg: Number of all possible PDG IDs.
:param emb_size: Dimension of embedded PDG space.
:param attention_heads: Number of attention heads for GAT Convolutional layers.
:param n_layers: Number of GAT Convolutional layers.
:param use_gap: Whether to use Global Attention Pooling (GAP) for the production of global features.

Definition at line 108 of file gatgap.py.

117 ):
118 """
119 Initialise the class.
120
121 :param units: Number of units for the output dimension of GAT Convolutional layers
122 as well as the dimension of global features.
123 :param num_features: Number of features attached to each node or particle as NN input.
124 :param num_pdg: Number of all possible PDG IDs.
125 :param emb_size: Dimension of embedded PDG space.
126 :param attention_heads: Number of attention heads for GAT Convolutional layers.
127 :param n_layers: Number of GAT Convolutional layers.
128 :param use_gap: Whether to use Global Attention Pooling (GAP) for the production of global features.
129 """
130 super().__init__()
131
132 self.pdg_embedding = torch.nn.Embedding(num_pdg + 1, emb_size)
133 in_feats = num_features + emb_size
134
135 self.gat_layers = torch.nn.ModuleList()
136 in_feats_glob = 0
137 for i in range(n_layers):
138 self.gat_layers.append(
139 GATModule(
140 in_feats=in_feats,
141 units=units,
142 num_heads=attention_heads,
143 in_feats_glob=in_feats_glob,
144 use_gap=use_gap
145 )
146 )
147 in_feats = units * attention_heads
148 in_feats_glob = units
149
150
151 self.fc_output = torch.nn.Linear(units, 1)
152

Member Function Documentation

◆ forward()

def forward (   self,
  graph 
)
Forward pass of the GATGAPModel.

Arguments:
    graph (torch.Tensor): DGLGraph representing the decay tree.

Returns:
    torch.Tensor: the final prediction with size 1.

Definition at line 153 of file gatgap.py.

153 def forward(self, graph):
154 """
155 Forward pass of the GATGAPModel.
156
157 Arguments:
158 graph (torch.Tensor): DGLGraph representing the decay tree.
159
160 Returns:
161 torch.Tensor: the final prediction with size 1.
162 """
163 h_pdg = graph.ndata["x_pdg"]
164 h_feat = graph.ndata["x_feature"]
165 h_pdg = self.pdg_embedding(h_pdg.long())
166 h = torch.cat((h_pdg, h_feat), axis=1)
167 hg = None
168 for layer in self.gat_layers:
169 h, hg = layer(graph, h, hg)
170 return self.fc_output(hg)

Member Data Documentation

◆ fc_output

fc_output

Output layer for final prediction.

Definition at line 151 of file gatgap.py.

◆ gat_layers

gat_layers

List of GAT modules to update node features.

Definition at line 135 of file gatgap.py.

◆ pdg_embedding

pdg_embedding

Embedding layer for PDG IDs.

Definition at line 132 of file gatgap.py.


The documentation for this class was generated from the following file: