Gumbel-Softmax makes categorical edge predictions usable in gradient-based models. It relaxes encoder logits into a continuous, differentiable distribution during training, then supports discrete edge samples during testing. section 6.5.4
In neural relational inference, the mechanism follows this pipeline:
- The encoder produces logits representing possible edge types, such as category 0 for disconnected and category 1 for connected. section 6.4 section 6.5.4
- Gumbel-Softmax converts those logits into edge distributions that remain differentiable, allowing reconstruction and KL-divergence losses to backpropagate. section 6.4 section 6.5.4
- The temperature controls distribution sharpness; the implementation uses 0.5, while hard sampling is enabled for discrete test-time edges. section 6.5.4
- The decoder receives sampled edge representations to reconstruct node data or predict future sensor trajectories. section 6.4
PyTorch NRI sampling
Flatten the encoder logits by edge type, call F.gumbel_softmax(logits, tau=0.5, hard=hard_sample), and reshape the result before passing it to the decoder. Training keeps samples differentiable; evaluation uses hard=True.
