liveBook · Manning

Property prediction loss

As explained in Graph Neural Networks in Action

A loss function that quantifies the discrepancy between predicted property values and their target values.

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

How Graph Neural Networks in Action covers it

How deep it goes
Defines property error as MSE and shows its integration with reconstruction, KL-divergence, and gradient-penalty terms.
Examples
Uses QED prediction for molecular graphs and implements MSE in a PyTorch loss function.
What you can do after
Apply it via PyTorch to train a molecular graph generator toward higher predicted QED values.
How it connects
Connects graph neural networks, variational graph autoencoders, latent representations, reconstruction loss, and KL divergence.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.