Spectral Encoders for Signal Classification
Designing neural network architectures that learn directly from spectral representations.
Learning from Spectra
Traditional signal classification pipelines extract hand-crafted features from spectral data before feeding them to a classifier. Spectral encoders bypass this step by learning features directly from frequency-domain representations.
Architecture Design
Our spectral encoder uses a 1D convolutional backbone operating on the power spectral density, followed by attention layers that learn to focus on the most informative frequency bands. The encoder maps input spectra to a compact latent space where structural similarity corresponds to geometric proximity.
class SpectralEncoder(nn.Module):
def __init__(self, n_freq=512, latent_dim=64):
super().__init__()
self.conv = nn.Sequential(
nn.Conv1d(1, 32, 7, padding=3),
nn.GELU(),
nn.Conv1d(32, 64, 5, padding=2),
nn.GELU(),
nn.AdaptiveAvgPool1d(64),
)
self.head = nn.Linear(64 * 64, latent_dim)
def forward(self, x):
h = self.conv(x.unsqueeze(1))
return self.head(h.flatten(1))
Training Strategy
We train with a contrastive loss that pulls spectra from the same structural class together and pushes spectra from different classes apart. This produces a latent space where k-NN classification achieves high accuracy.
Topics covered