Article

Derivatives

Exact gradients of decoded fields

A field decoded by Daedalus can be differentiated exactly, at the cost of one extra pass per axis, although the backbone is trained only to reconstruct values and never sees a derivative. This article explains why, and measures the decoded gradients on four smooth fields.

Based on Section 3 and Appendix B.3 of the paper

A pointwise decoder

The decoder answers a query point from three things only: the point's own coordinate, expressed in the local frame of each partition that contains it, the embedding ζm,p of that partition p, and its static frame, and from no other query point. The decoded field is therefore a neural field, a smooth function of position that can be evaluated anywhere, and the value at one point does not depend on where the other points are.

As a consequence, the Jacobian of all decoded values with respect to all query coordinates is zero between different points, since each point's value moves only with its own coordinate.

Forward-mode differentiation, step by step

Forward-mode automatic differentiation of the decoder. A small network of the decoder's shape, with fixed random weights, is run on a dual number, value + ε·slope, with the slope seeded on the coordinate and zero on ζm,p, and every number shown, the two derivative fields included, comes from that network. Click a stage to play it.

Forward-mode automatic differentiation carries, next to every value in the network, its rate of change along a chosen direction, and multiplies it by each layer's local rate on the way through, so the derivative comes out exactly, in the same pass as the value. With the direction e1 seeded at every query point at once, one pass returns ∂û/∂x1 at every point, because no point depends on another. A second pass with e2 returns ∂û/∂x2. The embedding is held fixed, with a rate of zero, so the derivative is with respect to space, and the value frame of the partition is inside the differentiated map, so the result is in physical units.

The Jacobian itself is never built. A forward-mode pass returns only the product of the Jacobian with the seeded direction, which here is exactly its diagonal: one derivative per point. Memory and time are those of a decoding that carries one extra number per axis, and both grow linearly with the number of points. The full Jacobian of N decoded values with respect to their 2N coordinates would hold 2N2 entries, about 34 GB in single precision for 65,536 points. This relies on the independence of the points: if the output of a decoder at one point depended on the other points, one pass would mix the derivatives of different points, and each point would need a pass of its own, or the whole Jacobian.

The derivative is exact and is computed together with the value, for every query point of a decoding, on any point cloud. The Derivatives demo runs the same computation on a formula or a painting, and the animation above traces one pass.

Accuracy without derivative supervision

Nothing in the training asks for derivatives. The backbone is trained only to reconstruct the values of analytic functions, and the gradient of a decoded field is obtained from this representation, which is shared by every task.

Decoded derivatives of four fields

The viewer shows four smooth fields on the unit disk, each encoded as a single partition from 16,384 random points and decoded on a pixel grid, with the gradient of the decoded field against the analytic one. The values are reconstructed to within 1% and each derivative to within 2%, with the error spread thinly apart from a few small spots. Derivatives are drawn in their own purple–orange colormap, distinct from that of the fields.

Field
Decoded derivatives of four smooth fields. The top row shows the field and its single-partition reconstruction, and each further row, for one axis, the analytic derivative, the derivative of the decoded field and their absolute difference, with the relative L2 error of the decoded derivative. The panels are pre-computed with the analysis backbone.

Applications

The accuracy of the decoded gradient is, first, a check on the representation. A field that only interpolated its encoded samples would have a noisy gradient, and an accurate gradient from a model never trained for one indicates that the decoded fields are smooth functions of position and that the embeddings they come from are meaningful points of a space of such functions.

The exact gradient also makes derivative fields inexpensive to obtain from any reconstruction or prediction. Strains and stresses follow from a decoded displacement field, fluxes from a decoded potential, and a PDE residual can be imposed directly on the decoded output of a latent operator, on any point cloud.

With several partitions the gradient is still exact for the decoded field, which is then assembled from the pieces of the partitions that contain each point, so near partition boundaries its accuracy depends on the overlap that averages those pieces.

Derivatives demo, on a formula or a painting →