Modified based on https://github.com/drorlab/gvp-pytorch/blob/main/gvp/models.py GVP-GNN for Model Quality Assessment as described in manuscript. Takes in protein structure graphs of type `torchdrug.data.Graph` or `torchdrug.data.PackedGraph` and returns a scalar representatio
| 160 | |
| 161 | @R.register("models.GVPGNN") |
| 162 | class GVPGNN(nn.Module, core.Configurable): |
| 163 | ''' |
| 164 | Modified based on https://github.com/drorlab/gvp-pytorch/blob/main/gvp/models.py |
| 165 | GVP-GNN for Model Quality Assessment as described in manuscript. |
| 166 | |
| 167 | Takes in protein structure graphs of type `torchdrug.data.Graph` |
| 168 | or `torchdrug.data.PackedGraph` and returns a scalar representation for |
| 169 | each graph and node in the batch in a `torch.Tensor` of shapes [n_nodes, d] |
| 170 | and [batch_size, d] |
| 171 | |
| 172 | :param node_in_dim: node dimensions in input graph, should be |
| 173 | (6, 3) if using original features |
| 174 | :param node_h_dim: node dimensions to use in GVP-GNN layers |
| 175 | :param node_in_dim: edge dimensions in input graph, should be |
| 176 | (32, 1) if using original features |
| 177 | :param edge_h_dim: edge dimensions to embed to before use |
| 178 | in GVP-GNN layers |
| 179 | :seq_in: if `True`, sequences will also be passed in with |
| 180 | the forward pass; otherwise, sequence information |
| 181 | is assumed to be part of input node embeddings |
| 182 | :param num_layers: number of GVP-GNN layers |
| 183 | :param drop_rate: rate to use in all dropout layers |
| 184 | ''' |
| 185 | def __init__(self, node_in_dim, node_h_dim, |
| 186 | edge_in_dim, edge_h_dim, readout="sum", |
| 187 | num_layers=3, drop_rate=0.1, |
| 188 | activations=(F.relu, None), vector_gate=True): |
| 189 | |
| 190 | super().__init__() |
| 191 | self.output_dim = node_h_dim[0] |
| 192 | self.rbf_dim = edge_in_dim[0] |
| 193 | |
| 194 | self.residue_embdding = nn.Linear(node_in_dim[0], node_in_dim[0], bias=False) |
| 195 | self.W_v = nn.Sequential( |
| 196 | layer.GVPLayerNorm(node_in_dim), |
| 197 | layer.GVP(node_in_dim, node_h_dim, activations=(None, None), vector_gate=vector_gate) |
| 198 | ) |
| 199 | self.W_e = nn.Sequential( |
| 200 | layer.GVPLayerNorm(edge_in_dim), |
| 201 | layer.GVP(edge_in_dim, edge_h_dim, activations=(None, None), vector_gate=vector_gate) |
| 202 | ) |
| 203 | |
| 204 | self.layers = nn.ModuleList( |
| 205 | layer.GVPConvLayer(node_h_dim, edge_h_dim, drop_rate=drop_rate, |
| 206 | activations=activations, vector_gate=vector_gate) |
| 207 | for _ in range(num_layers)) |
| 208 | |
| 209 | ns, _ = node_h_dim |
| 210 | self.W_out = nn.Sequential( |
| 211 | layer.GVPLayerNorm(node_h_dim), |
| 212 | layer.GVP(node_h_dim, (ns, 0), activations=activations, vector_gate=vector_gate) |
| 213 | ) |
| 214 | |
| 215 | if readout == "sum": |
| 216 | self.readout = layers.SumReadout() |
| 217 | elif readout == "mean": |
| 218 | self.readout = layers.MeanReadout() |
| 219 | else: |
nothing calls this directly
no outgoing calls
no test coverage detected