
Choose an executable path, not just a model name
Before adapting a hyperspectral foundation model, choose the exact entry point you intend to run. A repository can contain pretraining encoders, task-specific wrappers, several dataset loaders and different checkpoint-merging procedures. Their input requirements need not be identical.
This walkthrough inspects two public code paths: SpectralGPT’s 96-pixel spectral pretraining configuration and HyperSIGMA’s image-segmentation example. It is a source-code audit, not a new benchmark or a claim that the models have been run on a particular sensor.
The examples are pinned to SpectralGPT revision 56d2c4d5c7577e16075f0ca57bd6c4ba9d35a100 and HyperSIGMA revision 07e9ea24e3072fcb5c3a92a2bcb8185e43b295b9, reviewed on 22 October 2026. Use the linked files to check the described behaviour rather than assuming the current default branch is unchanged. For the broader research context, see foundation models for hyperspectral imaging.
SpectralGPT: distinguish the public input from the internal tensor
The released first-stage training command selects mae_vit_base_patch8_96, the tensor model path, a 96-pixel input and the Sentinel dataset loader. It also requests removal of band index 10. That is a configuration-specific array index, not an instruction to remove a wavelength named “10” from arbitrary imagery. Verify the dataset’s ordered band list before assigning physical meaning to it. [1]
In models_mae_spectral.py, the selected factory fixes in_chans=1, num_frames=12 and t_patch_size=3. Its encoder inserts a singleton dimension into the supplied tensor. The public input for this path is therefore (batch, 12, 96, 96); inside the encoder it becomes (batch, 1, 12, 96, 96). Adding that singleton dimension in the loader as well would produce the wrong rank. [2]
The inherited name num_frames refers to the spectral-axis length in this use of the code, not twelve observation dates. The separate patch-embedding implementation checks the configured spatial dimensions and axis length before applying a 3D convolution. Read those executable checks when interpreting a shape error; some inherited comments use older image or video terminology. [3]
Derive the token grid from the selected configuration
For the 96-pixel configuration, spatial patches are 8 × 8 and spectral groups contain three of the twelve input bands. The unmasked grid therefore has 4 × 12 × 12 = 576 tokens. A 128-pixel spatial input with the same spectral grouping would have 4 × 16 × 16 = 1,024 tokens when used with the corresponding 128-pixel configuration. These are arithmetic consequences of the patch geometry, not throughput measurements. [2] [3]
The distinction matters when changing a crop size or loading positional embeddings. Divisibility alone is insufficient if the selected implementation also asserts an exact size. Likewise, a cube with 120 bands is not compatible with this particular twelve-band configuration merely because 120 is divisible by three.
Record the constructor, crop dimensions, spectral length and token grid together. Do not repair a mismatch by reshaping until the error disappears. Reshaping can mix spatial positions and spectral observations while producing dimensions that look acceptable.
Trace the active preprocessing, including commented-out alternatives
In the pinned SpectralGPT Sentinel loader, the active image-reading path performs per-image, per-band min–max scaling across the two spatial axes, with a small denominator offset. Its transform then converts the array to a tensor and applies the selected spatial augmentation. The calls to SentinelNormalize in that loader’s transform are commented out. Their presence elsewhere in the file does not make them active. [4]
The same loader removes the requested indices after the image transform. To reproduce this route, trace the actual order: file decoding, scaling, tensor conversion, spatial transform and channel selection. Log a small sample’s shape, dtype and per-band range at those boundaries. Check the evaluation branch separately because its spatial transform differs from training. [4]
This audit describes the inspected source revision. It does not establish that every historical weight file was trained with exactly that revision. If checkpoint metadata does not identify the preprocessing release, preserve that uncertainty. Reproducing current code and reproducing the original checkpoint’s training distribution are different goals.
Min–max scaling also changes the interpretation of values. Two bands with different absolute reflectance levels can each span a similar normalised range. Keep the calibrated physical data alongside network inputs, and do not relabel normalised values as measured reflectance.
Sources: [4]
HyperSIGMA: distinguish sensor bands, PCA components and spectral tokens
The selected HyperSIGMA segmentation notebook applies PCA and passes pca_components as in_channels to SSFusionFramework. Its Indian Pines configuration specifies 20 components. In that example, the network’s channel axis contains PCA features rather than twenty individually identified sensor wavelengths. A different task or notebook must be audited separately. [5]
The fusion wrapper constructs spatial and spectral branches and sets NUM_TOKENS to 100. In the spectral branch, adaptive average pooling maps the feature-channel axis to that token count. Consequently, “100 spectral tokens” does not tell you that the incoming observation contains 100 raw bands. The implementation also maps the flattened spatial dimension through a linear layer sized from img_size. [6] [7]
Preserve the PCA transform with a pipeline that uses it: the fitted components, centring information, selected dimension and fitting population are part of the input contract. PCA features do not have one-to-one band-centre wavelengths. If the experiment instead supplies raw sensor channels, describe that change explicitly and assess its compatibility with the chosen architecture and weights.
For an inductive evaluation, fit PCA on training observations only. An exact reproduction of a released example may follow a different data-access protocol. Document that protocol, then keep a revised train-only experiment separate rather than silently changing the procedure while claiming an exact reproduction. [10]
Check transferred weights before the final dictionary is merged
A successful checkpoint load can conceal how much of the new model remained at its initial values. The selected HyperSIGMA notebook starts with the newly constructed model’s state dictionary, filters and prefixes parameters from the spatial and spectral checkpoints, overlays matching entries, then loads the resulting complete dictionary. Because that dictionary already contains the model’s own entries, key completeness at the last step does not prove that every entry came from pretraining. [5]
Audit the incoming checkpoint mapping before that overlay. For each candidate parameter or buffer, record whether it is transferred unchanged, renamed, interpolated, excluded, absent or shape-incompatible. Include the reason. A task head newly initialised for the target labels may be expected; an unexpectedly untransferred encoder block requires investigation.
The spatial branch also exposes an initialisation routine that removes checkpoint projection entries when its configured channel count differs from three. This is behaviour of that particular routine, not a universal HyperSIGMA loading rule; the notebook’s manual merge is a separate path. Inspect whichever path your program actually calls. [8]
PyTorch’s load_state_dict reports missing and unexpected keys and can require an exact key match. Those checks are useful, but they do not establish parameter provenance or physical input compatibility. Keep the pre-merge transfer audit as well as the final load report. [9]
Use three small checks before a training run
First, check the interface with one batch. Verify the rank, named axis order, floating-point dtype, finite values, spatial dimensions and feature count at the public model boundary. For a raw-band input, compare the ordered band identifiers against a separately reviewed manifest. Checking only that the count is twelve would miss a permutation. For PCA input, check the transform identity and component order instead.
Second, check a deliberately broken case. Swap two channel identifiers, change the spatial size or insert an extra axis and confirm that the preflight rejects it with a useful explanation. A guard that never fails on a known mismatch gives little confidence. The expected metadata must come from the contract, not be regenerated from the same possibly incorrect array order.
Third, inspect checkpoint transfer before running a forward pass. Compare source and destination shapes, preserve excluded keys, and account for intended adaptations. Then run a small inference-mode smoke test in the documented environment and check the output’s structure and finiteness. A finite output establishes only that this computation completed; assess task quality separately.
Do not use random tensors as evidence of spectral validity. Synthetic tensors are suitable for exercising shape checks. Real calibrated samples, known metadata and the original preprocessing path are needed to inspect numerical meaning.
Write the audit result so someone else can reproduce it
A compact audit should name the repository revision, entry point, model constructor and checkpoint checksum. Save preprocessing code and parameters, the exact ordered features, numeric transformations, crop policy and invalid-data handling. Include the transfer decisions and the observed input and output shapes from the smoke test.
Separate three outcomes in the report: interface checks passed; checkpoint transfer behaved as intended; downstream performance met the stated criterion on independent data. If only the first two have been established, say so. A successful load and a finite prediction are useful engineering milestones without being evidence of sensor transfer or scientific accuracy.
When the audit reveals a physical sensor mismatch, continue with adapting spectral foundation models to a new sensor. That guide covers wavelength support and response functions. The present audit supplies the executable details needed to decide what, exactly, is being adapted.
Frequently asked questions
Does SpectralGPT always require twelve bands?
No universal claim is made here. The pinned factory examined in this article fixes twelve spectral inputs. Other configurations, adaptations or implementations must be checked on their own terms.
Does HyperSIGMA use one spectral token per sensor band?
Not in the selected segmentation implementation. Its wrapper sets an internal token count and the spectral branch uses adaptive pooling. The input may also have undergone PCA, so raw-band count, feature count and token count are distinct.
Does a strict checkpoint load prove every parameter was pretrained?
No. It checks key compatibility with the dictionary supplied to the loader. If that dictionary was first populated from the new model and then partially overwritten, it can be complete while some entries retain their initial values.
References and further reading
- SpectralGPT: pinned README and first-stage training command
- SpectralGPT: pinned spectral model factory and encoder
- SpectralGPT: pinned 3D patch embedding and input assertions
- SpectralGPT: pinned dataset loaders and transforms
- HyperSIGMA: pinned segmentation notebook, PCA and checkpoint merge
- HyperSIGMA: pinned segmentation fusion wrapper
- HyperSIGMA: pinned spectral branch and token pooling
- HyperSIGMA: pinned spatial branch and initialisation routine
- PyTorch: Module.load_state_dict
- scikit-learn: Data leakage and recommended practices
Reader feedback
Reads since 1 October 2026: at least 15 seconds with the article visible, counted once per browser per day. Reactions are anonymous and can be changed.
Loading reader feedback…
Discuss this article
Ask a technical question, challenge an assumption or share evidence from your own work.