liveBook · Manning

Reconstruction loss

As explained in Graph Neural Networks in Action

A measure of the discrepancy between an input and the output reconstructed from its latent representation.

Reconstruction loss measures how far a decoder’s output is from what it should reproduce. An autoencoder compresses an input into a latent representation, decodes it, and trains to reduce the difference between the input and its reconstruction. For graphs, that output can be a predicted adjacency matrix; for temporal data, it can be the next pose in a sequence. section 5.5 section 5.4.2 section 6.4

To use it in a training loop:

  • Run the encoder and decoder, then compare the decoder’s prediction with the corresponding target. In molecular graph generation, the target adjacency matrix is built from the graph’s edges. section 5.4.4
  • Choose a comparison suited to the output: the molecular graph example uses binary cross-entropy for adjacency matrices; the pose-prediction example uses mean squared error against the next timesteps, scaled by prior variance. section 5.4.2 section 6.4
  • Combine reconstruction loss with the model’s other objectives before backpropagation. The molecular VGAE adds KL divergence and QED prediction loss; neural relational inference pairs reconstruction loss with KL divergence. section 5.4.2 section 6.4.3

Molecular graph loss in PyTorch

For predicted and true adjacency matrices, `F.binary_cross_entropy(pred_adj, true_adj)` supplies the reconstruction term. The loss function adds QED mean squared error and KL divergence. The decoder also produces a feature matrix, but the displayed loss calculation explicitly applies binary cross-entropy to adjacency only; do not assume this line trains feature reconstruction. section 5.4.2 section 5.4.3

A falling combined training loss is useful feedback, but it does not by itself verify that generated molecules are valuable: proposed candidates still need further testing. Likewise, future-pose prediction is evaluated separately at different time horizons. section 5.4.4 section 6.4.3

How Graph Neural Networks in Action covers it

How deep it goes
Defines reconstruction error through an autoencoder, then implements adjacency binary cross-entropy and scaled pose mean squared error without a formal derivation.
Examples
Uses molecular adjacency matrices with QED prediction and sensor-pose trajectories with next-timestep targets.
What it assumes
Introduces encoders, decoders, and latent space through image reconstruction before applying the idea to graphs.
What you can do after
Apply it via PyTorch loss functions when training molecular graph generators or neural relational inference models.
How it connects
Links autoencoders, latent representations, variational graph autoencoders, KL divergence, property prediction, and neural relational inference.

Also explained in

Compare how 10 books explain reconstruction loss →

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.