Initializes the GAT model. Args: in_features (int): number of input features per node. n_hidden (int): output size of the first Graph Attention Layer. n_heads (int): number of attention heads in the first Graph Attention Layer. num_classes (
(self,
in_features,
n_hidden,
n_heads,
num_classes,
concat=False,
dropout=0.4,
leaky_relu_slope=0.2)
| 147 | And the second (final) layer is a GAT layer with a single attention head and softmax activation function. |
| 148 | """ |
| 149 | def __init__(self, |
| 150 | in_features, |
| 151 | n_hidden, |
| 152 | n_heads, |
| 153 | num_classes, |
| 154 | concat=False, |
| 155 | dropout=0.4, |
| 156 | leaky_relu_slope=0.2): |
| 157 | """ Initializes the GAT model. |
| 158 | |
| 159 | Args: |
| 160 | in_features (int): number of input features per node. |
| 161 | n_hidden (int): output size of the first Graph Attention Layer. |
| 162 | n_heads (int): number of attention heads in the first Graph Attention Layer. |
| 163 | num_classes (int): number of classes to predict for each node. |
| 164 | concat (bool, optional): Wether to concatinate attention heads or take an average over them for the |
| 165 | output of the first Graph Attention Layer. Defaults to False. |
| 166 | dropout (float, optional): dropout rate. Defaults to 0.4. |
| 167 | leaky_relu_slope (float, optional): alpha (slope) of the leaky relu activation. Defaults to 0.2. |
| 168 | """ |
| 169 | |
| 170 | super(GAT, self).__init__() |
| 171 | |
| 172 | # Define the Graph Attention layers |
| 173 | self.gat1 = GraphAttentionLayer( |
| 174 | in_features=in_features, out_features=n_hidden, n_heads=n_heads, |
| 175 | concat=concat, dropout=dropout, leaky_relu_slope=leaky_relu_slope |
| 176 | ) |
| 177 | |
| 178 | self.gat2 = GraphAttentionLayer( |
| 179 | in_features=n_hidden, out_features=num_classes, n_heads=1, |
| 180 | concat=False, dropout=dropout, leaky_relu_slope=leaky_relu_slope |
| 181 | ) |
| 182 | |
| 183 | |
| 184 | def forward(self, input_tensor: torch.Tensor , adj_mat: torch.Tensor): |
no test coverage detected