Why convert objects to continuous fields

Many prediction problems have sets as outputs, and the size of the set changes from one example to the next. An image contains a different number of objects each time, a molecule has a different number of atoms, and a radio-telescope light curve can be explained by a different number of bursts.

In regression, the number of objects is itself something to predict. A model that counts the digits in an image or the bursts in a light curve outputs an integer that changes with the input, together with every object's position and attributes. Common solutions are a fixed number of output slots, as in DETR [1], which caps the number of objects the model can return, or a dedicated head that predicts the count.

In generation, a model typically has to decide the number of objects first. For a molecule, the number of atoms is sampled before the geometry, often from a separate distribution or count model, as in EDM [2], and positions and atom types are then generated for that many atoms. The alternative is to pad every example to a maximum size and let the model switch the extra entries off. Both become awkward when the count should depend on a continuous condition such as a molecular property: binning the property together with the number of atoms leaves no way to sample a count for a bin the training data never contained.

CORDS (Continuous Representations of Discrete Structures) removes the separate count. A set of objects with positions and attributes becomes two continuous fields, a density that encodes where the objects are and a feature field that carries their attributes. Every object adds one unit of mass to the density, so the number of objects is the total mass, \(N = \int \rho(\mathbf r)\,d\mathbf r\). A model that predicts the fields predicts the count together with positions and attributes, and the count is a continuous, differentiable function of the density. There is no count model, padding or fixed slots, and the fields can be turned back into a set.

Voxel and neural-field representations of molecules and proteins [3, 4, 5] also avoid fixing the size, but they recover the atoms afterwards by peak finding or a learned decoder; the count and the attributes are not read from the representation itself.

Three stacked planes. Top: an image of overlapping MNIST digits with colored bounding boxes. Middle: the density field rho(r) as gray contours with one bump per digit. Bottom: the per-class feature fields h_k(r) in colors. Drop lines connect each digit to its bump.
An image with N MNIST digits (top) is encoded into a density field \(\rho(\mathbf r)\) (middle) and per-class feature fields \(h_k(\mathbf r)\) (bottom). The number of objects is the density mass, \(N = \int \rho(\mathbf r)\,d\mathbf r\).
Paper: CORDS: Continuous Representations of Discrete Structures, with Erik Bekkers, Michael Tiemann and Jan-Willem van de Meent, ICLR 2026. Code: github.com/stases/CORDS.

Density and feature fields

Encoding

Take a set of \(N\) objects, where object \(i\) has a position \(\mathbf r_i \in \mathbb R^d\) and an attribute vector \(\mathbf x_i \in \mathbb R^c\). The space can be the image plane, three-dimensional space or a time axis. For an atom, \(\mathbf x_i\) can be a one-hot encoding of its element. For a digit in an image, it holds the class and the width and height of its box.

We place a Gaussian with unit integral and width \(\sigma\), \(\kappa_\sigma(\mathbf r) = (2\pi\sigma^2)^{-d/2} \exp(-\lVert\mathbf r\rVert^2 / 2\sigma^2)\), at each position and build two fields:

$$ \rho(\mathbf r) = \sum_{i=1}^{N} \kappa_\sigma(\mathbf r - \mathbf r_i), \qquad \mathbf h(\mathbf r) = \sum_{i=1}^{N} \mathbf x_i\, \kappa_\sigma(\mathbf r - \mathbf r_i). $$

The density \(\rho\) has one bump per object. Each of the \(c\) channels of \(\mathbf h\) is the same sum with every bump scaled by the object's value of that attribute. The sums do not depend on the order of the objects, so the encoding is permutation invariant. Every bump has integral one, so

$$ N = \int \rho(\mathbf r)\, d\mathbf r. $$

The count is the total mass of the density.

A ball-and-stick molecule above two planes: the density field as gray contours and the feature fields in colors by atom type, with drop lines from each atom to its bump.
A molecule (top) with its density field (middle) and feature fields, one per atom type (bottom). The fields live in three-dimensional space; the planes are a two-dimensional view. The number of atoms is the density mass.

Decoding

We recover the set in three steps. Count: the total mass of the density gives the number of objects \(\hat N\).

Positions. Find the \(\hat N\) centers whose kernels add up to the density,

$$ \min_{\hat{\mathbf r}_1, \ldots, \hat{\mathbf r}_{\hat N}} \int \Big( \rho(\mathbf r) - \sum_{j=1}^{\hat N} \kappa_\sigma(\mathbf r - \hat{\mathbf r}_j) \Big)^{2} d\mathbf r. $$

For a field from the encoder, the original positions minimize this. For molecules we start from a Gaussian mixture fit to the samples and refine the centers with L-BFGS; for images we start from the peaks of the density.

Attributes. With the centers fixed, \(\mathbf h\) is a sum of the same kernels, each weighted by its object's attributes, so the attributes are the solution of one small linear system whose matrix holds the overlaps between kernels. Solving it separates neighboring kernels again; for categorical attributes we take the largest channel.

For fields produced by the encoder and evaluated exactly, the three steps return the original set up to order, provided the kernels at distinct centers are linearly independent and a sum of equal-weight kernels determines its centers. In practice the fields are known at finitely many points, nearby kernels overlap, and a model's prediction is only approximately the encoding of a set; each of these limits the accuracy of the decoded set.

Sampling the fields

A network cannot take a continuous function as input, so we evaluate the fields at \(M\) locations \(\mathbf r_s\) and give the network the tuples \((\mathbf r_s, \rho(\mathbf r_s), \mathbf h(\mathbf r_s))\). There are two ways to choose the locations.

Uniform sampling evaluates the fields on a regular grid. It suits images and time series, which already lie on grids. For molecules a grid is inefficient: the molecule fills a small part of space, the number of grid points grows cubically with the resolution, and a fixed box imposes boundaries. For molecules we use importance sampling instead. We draw locations with probability proportional to the density and evaluate the fields there. The samples concentrate where the atoms are, no bounding box is needed, and the model can learn the coordinates and the field values jointly for molecules of any size.

Two panels of a two-dimensional density with feature-field colors: on the left, sample points concentrated around the density bumps; on the right, sample points on a regular grid.
Sampling strategies for evaluating fields. Left: importance sampling draws coordinates in proportion to \(\rho\). Right: uniform sampling evaluates the fields on a fixed grid. The curves are isocontours of \(\rho(\mathbf r)\) and the colors show the feature fields \(h_k(\mathbf r)\).

The sampling scheme decides the network. Importance samples form a large unordered point set, and we process it with Erwin [6], a hierarchical transformer that scales to thousands of points. Images and time series use ordinary 2D and 1D convolutional networks (CNNs).

On samples, the decoder replaces its integrals by weighted sums. A density predicted by a model rarely sums to an exact integer, so the count estimate is rounded. For generated molecules the sampling distribution is not known, so we train with the density rescaled so that its mean over the samples equals the number of atoms, and at generation time the rounded mean of the generated density is the count.

The fields of a molecule, computed live. Choose a molecule, \(\sigma\), the sampling scheme and the number of samples \(M\), and view the density or the feature field of one element. Atoms and their feature fields share one color per element: H amber, C blue, N teal, O red, F pink. Decode recovers the count \(\hat N\), the positions and the types from the samples and reports their errors. No trained model is involved: these are encode-decode roundtrips of the exact fields.

Molecules, detection and inference

Molecules

We use QM9, small organic molecules [7], and GEOM-Drugs, larger drug-like molecules [8]. Each atom carries its element and, on GEOM-Drugs, its charge. At every training step we encode the molecule, draw \(M\) importance samples and give them to Erwin. For generation, a diffusion model denoises the sample locations and the field values together, so the number of atoms, their positions and their elements all come out of the generated fields; we decode to atoms only for the metrics that need a molecular graph.

On QM9, the molecule stability is 82.3% under the standard RDKit evaluation, against 82.0% for EDM [2] and 89.4% for GeoLDM [9]; under the protocol of VoxMol and FuncMol, which also use continuous representations, it is 93.8%, about 4.5 points above both [3, 4]. On GEOM-Drugs the atom stability is behind EDM and GeoLDM. Without an equivariant backbone, the model is competitive with equivariant graph networks, though the strongest of them are ahead.

Because the count comes out of the fields, conditional generation needs no separate count model. We condition on a continuous property, the polarizability, without binning it or the number of atoms. To test generalization, we remove a range of polarizability from training and condition on it at inference.

Histogram of the number of atoms N from 13 to 22. The generated distribution (orange bars) follows the data (blue outline), with a lower peak at 19 and more weight at 21 and 22.
Conditional generation on QM9. The distribution of the number of atoms \(N\) of generated molecules (bars) and of the data (outline), conditioned on a polarizability range that was unseen during training. The generated counts follow the data but are flatter, with less weight on the most common count and more on the largest ones.

The same sampled fields also serve property regression, where the network pools its output and nothing is decoded.

Object detection on MultiMNIST

The objects are the bounding boxes of digits, each with a center, a class and a size. We encode a scene into a density on the image plane, one feature channel per class and two channels for the width and height; the first figure shows the density and the class channels. A small CNN predicts these fields from the image, and the decoder turns them into boxes. Scenes are generated on the fly with up to 15 digits.

We compare with a DETR-style detector with 15 queries and an anchor-free YOLO-style detector [10], all with about 8 million parameters, on a split with exactly 16 digits per image, one more than the training maximum. Between the two splits the average precision (AP) of CORDS falls by 16.4% in relative terms (from 76.8 to 64.2), against 19.5% for DETR and 24.5% for YOLO; DETR stays ahead in absolute AP (65.4 against 64.2 on 16 digits). The comparison measures how AP degrades in a denser scene.

A MultiMNIST scene above its density and feature planes, as in the first figure. Change the number of digits \(N\) (the paper trains on up to 15), \(\sigma\), the grid resolution or the number of importance samples, and the feature channel, then decode the boxes and the count. A larger \(\sigma\) or a coarser grid makes neighboring digits harder to separate. No trained detector is involved: these are encode-decode roundtrips of the exact fields.

Simulation-based inference for fast radio bursts

Fast radio bursts are millisecond-scale flashes of extragalactic radio emission [11, 12]. In our simulator a light curve of photon counts with Poisson noise is a sum of one to six transient components, each with an onset time, an amplitude, a rise time and a skewness, and the task is to infer the posterior over these parameters, including their number, from the observed curve. We put a density \(\rho(t)\) on the time axis with a bump at each onset time and a feature field that carries the other three parameters, append the observed light curve on a grid of 1,000 time points, and train a flow-matching model [13] to sample fields given the curve. Each sampled field decodes to a count and a set of components, so many samples give the posterior over the count with no separate count model.

Left: a noisy simulated light curve with five bursts, the predictive median and its 50% band following it, and dashed lines at the true burst locations. Right: a histogram of the decoded number of components with most of the mass on the true count of five.
Simulation-based inference on light curves. Left: an observed light curve with reconstructions from posterior samples; each sample is decoded into component parameters and the light curve is simulated again. Right: the posterior over the number of components for the same observation. About three quarters of the posterior mass sits on the true count of five and most of the rest on six.

Summary and limitations

CORDS maps a set of spatial objects with attributes to a density field and feature fields, and back. The count is the total mass of the density, so a model that works in field space handles sets of different sizes with the same network, without a separate count model, padding or fixed slots. The same encoding and the same three decoding steps serve molecules, images and time series, with different networks and training objectives in each.

The method has costs. High-fidelity reconstruction of molecules benefits from dense sampling, on the order of \(10^3\) points each, which makes larger molecules expensive. Decoding adds cost: on QM9, fitting the positions takes 20.0 ms per molecule on an H100 in a prototype implementation, against 58.8 ms for sampling with 30 steps. In detection, overlapping kernels make nearby objects hard to separate and the kernel width needs tuning. The exact inverse holds for fields produced by the encoder, and fields predicted by a model are decoded approximately. Detection is tested only on MultiMNIST, and larger benchmarks such as COCO remain open.

The code is a beta release with the transform, the reconstruction tools and notebooks for molecules and MNIST detection; its training configurations are small demonstrations.

Selected references

  1. Carion et al. (2020). End-to-End Object Detection with Transformers. ECCV.
  2. Hoogeboom et al. (2022). Equivariant Diffusion for Molecule Generation in 3D. ICML.
  3. Pinheiro et al. (2023). 3D molecule generation by denoising voxel grids. NeurIPS.
  4. Kirchmeyer et al. (2024). Score-based 3D molecule generation with neural fields. NeurIPS.
  5. Faltings et al. (2025). ProxelGen: Generating Proteins as 3D Densities. arXiv preprint.
  6. Zhdanov et al. (2025). Erwin: A Tree-based Hierarchical Transformer for Large-scale Physical Systems. ICML.
  7. Ramakrishnan et al. (2014). Quantum chemistry structures and properties of 134 kilo molecules. Scientific Data.
  8. Axelrod and Gómez-Bombarelli (2022). GEOM, energy-annotated molecular conformations for property prediction and molecular generation. Scientific Data.
  9. Xu et al. (2023). Geometric Latent Diffusion Models for 3D Molecule Generation. ICML.
  10. Wang et al. (2024). YOLOv10: Real-Time End-to-End Object Detection. NeurIPS.
  11. Petroff et al. (2022). Fast radio bursts at the dawn of the 2020s. The Astronomy and Astrophysics Review.
  12. Zhang (2023). The physics of fast radio bursts. Reviews of Modern Physics.
  13. Dax et al. (2023). Flow Matching for Scalable Simulation-Based Inference. NeurIPS.