Skip to content

Generalise SpacetimeEncoder, freeze the EPJ-C variant - #920

Open
sevmag wants to merge 1 commit into
graphnet-team:mainfrom
sevmag:feature/spacetime-encoder-config
Open

Generalise SpacetimeEncoder, freeze the EPJ-C variant#920
sevmag wants to merge 1 commit into
graphnet-team:mainfrom
sevmag:feature/spacetime-encoder-config

Conversation

@sevmag

@sevmag sevmag commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Generalises SpacetimeEncoder so it can be used on detectors other than the one it was written for, keeping the published version unchanged under a new name — the same treatment #913 gives FourierEncoder.

SpacetimeEncoder hardcodes four properties of the Kaggle dataset's normalisation: position in columns 0-2 and time in column 3; the constant 3e4 / 500 * 3e-1 converting time into a length; the 1024 multiplier and ladder span that set which separations the embedding resolves; and the ±4 clip.

Changing numerical ranges in the feature standardization or for different detectors requires a configurable time weighting in the difference.

Changes

  • SpacetimeEncoderEPJC — the existing class, unchanged, with its assumptions documented. IceMix/DeepIce use it, so their output is bit-for-bit what it was.
  • SpacetimeEncoder — the same computation with columns, time_scale, scale, clip, n_freq and output_dim supplied by the caller; the defaults reproduce the EPJC band.
  • signed_four_distance() — the interval lifted out so both classes share one implementation.
  • SinusoidalPosEmb.n_freq widened from int to float, since a matched span is generally not an integer, and its docstring corrected: it sets the ladder's span, not the number of frequencies (that is dim / 2).

Verified against a pinned copy of the pre-refactor class: the EPJC path, the configurable path at EPJC settings, and a column-permuted input all reproduce the original embedding exactly (max|d| = 0). Pre-commit clean.

The spacetime encoder hardcoded the Kaggle dataset's normalisation: position
in columns 0-2 and time in column 3, the constant converting time into a
length, the multiplier setting the resolved band, and the clip. On other data
those choices are silently wrong -- a mismatched time constant reduces the
interval to a spatial distance.

Keep the shipped behaviour as SpacetimeEncoderEPJC and add a general
SpacetimeEncoder taking columns, time_scale, scale, clip and n_freq, mirroring
the FourierEncoder split. IceMix uses the EPJC variant, so its output is
unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F75gXoxTcs4nVRxGp91ENf
@sevmag
sevmag force-pushed the feature/spacetime-encoder-config branch from 63e6a34 to dbc9960 Compare September 11, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant