Property prediction loss measures the mean squared error (MSE) between a graph property predicted from its latent representation and the corresponding target value. In molecular graph generation, the property is QED, a measure the model is trained to increase while proposing new molecules. section 5.4.2
Within a variational graph autoencoder, the loss follows a short pipeline:
- Encode the molecular graph into a latent representation and reparameterize it into z. section 5.4.3
- Pass z through a linear property-prediction layer to produce a predicted QED value. section 5.4.3
- Compare predicted and actual QED with MSE, then backpropagate the prediction error through the model. section 5.4.2 section 5.4.4
- Add the property loss to adjacency reconstruction loss and KL-divergence loss; training can also include a gradient penalty. section 5.4.4
QED loss in a molecule generator
A loss function can compute `qed_loss = F.mse_loss(qed_pred.view(-1), qed_true.view(-1))` and return `adj_loss + qed_loss + kl_loss`. This trains the generator to reconstruct molecular graphs while organizing latent space around molecules with higher QED. section 5.4.2 section 5.4.4
Listing 5.18 Loss for molecule graph generation
def calculate_loss(self, pred_adj, \
true_adj, qed_pred, qed_true, mu, logvar):
adj_loss = F.binary_cross_entropy\
(pred_adj, true_adj) #1
qed_loss = F.mse_loss\
(qed_pred.view(-1), qed_true.view(-1)) #2
kl_loss = -0.5 * torch.mean\
(torch.sum(1 + logvar - mu.pow(2)\ #3
- logvar.exp(), dim=1))
return adj_loss + qed_loss + kl_loss
Use the complete loss implementation to inspect how MSE property error is combined with adjacency reconstruction and KL-divergence terms. section 5.4.2
