specsr.models.sr1

SR1 — the super-resolution backbone (stage 1 of 3).

Maps a low-resolution prism spectrum, already interpolated onto the common high-resolution wavelength grid, to a super-resolved estimate with a wavelength-dependent predictive uncertainty.

SR1 is deliberately conservative: it recovers broad structure and begins to sharpen lines, but is not asked to synthesise fine detail on its own. That is left to specsr.models.sr2, which refines the SR1 output using an explicit emission-line prior conditioned on an inferred redshift.

Note

SR1 is not the same operation as the interpolation applied during preprocessing. Preprocessing resamples the prism spectrum onto the target wavelength grid, changing the sampling but not the information content. SR1 is trained against the medium-resolution reference and learns to redistribute flux into narrower features, which changes the effective resolution. The interpolation step supplies SR1’s input grid; it does not do SR1’s job.

Classes

SuperRes1D(*args, **kwargs)

1D ResNet-style super-resolution backbone with heteroscedastic output.

class specsr.models.sr1.SuperRes1D(*args, **kwargs)[source]

Bases: Module

1D ResNet-style super-resolution backbone with heteroscedastic output.

Parameters:
  • in_channels (int) – Number of input channels. 1 for flux alone.

  • hidden_dim (int) – Width of the residual trunk.

  • num_res_blocks (int) – Number of ResidualBlock1D blocks.

  • dropout (float) – Dropout probability inside each residual block.

  • activation_fn (nn.Module | None) – Activation applied after the input convolution.

Returns:

Both shaped (B, 1, L). log_var is the log of the model variance; the measurement variance of the reference spectrum is added separately in the loss, so the two noise sources stay distinguishable.

Return type:

mean, log_var

Notes

The log-variance head is initialised to a constant -2.0 bias with zero weights, so the model starts by predicting a small, uniform uncertainty (sigma ~ 0.37 in normalised units). Starting from a data-dependent variance lets the network drive the likelihood down by inflating uncertainty before it has learned anything, which stalls training.

forward(x)[source]
Parameters:

x (torch.Tensor)

Return type:

tuple[torch.Tensor, torch.Tensor]