Teaching neural nets to draw with sine waves
A lean PyTorch implementation of SIREN that turns pixel coordinates into images using nothing but sine-activated MLPs.

What it does
SIREN swaps the usual ReLUs in a multilayer perceptron for sine activations, letting the network represent fine details—an image, a waveform, a 3D shape—as a continuous function of raw coordinates. This repo packages that idea into SirenNet and Siren layers, plus a SirenWrapper that handles the busywork of teaching an MLP to memorize one specific image from (x, y) inputs.
The interesting bit
The first layer’s w0_initial acts like a tuning knob for frequency: too low and the network blurs the details, too high and it hallucinates high-frequency noise. The repo also quietly implements a follow-up paper, letting you steer the whole network with a latent vector that elementwise-modulates every hidden layer.
Key highlights
SirenNetexposes a full sine-activated MLP for any coordinate-based regression task.SirenWrapperabstracts the drudgery of overfitting a single image: instantiate with height and width, train on a tensor, then call it bare to reconstruct.- Latent conditioning is available via a
latent_dimargument, wiring in a modulator feedforward network per the 2021 paper. Sineis included as a standalone activation wrapper aroundtorch.sinif you want to roll your own.
Caveats
- The wrapper API is clearly designed to overfit one image at a time; the README is vague on whether it generalizes to batched training across a dataset.
- No benchmarks, pretrained weights, or examples beyond the basic API snippets are shown.
Verdict
Grab it if you are prototyping neural representations, image fitting, or coordinate-based generative tricks. Look elsewhere if you need a general vision backbone or a scalable data-loader-friendly trainer.
Frequently asked
- What is lucidrains/siren-pytorch?
- A lean PyTorch implementation of SIREN that turns pixel coordinates into images using nothing but sine-activated MLPs.
- Is siren-pytorch open source?
- Yes — lucidrains/siren-pytorch is open source, released under the MIT license.
- What language is siren-pytorch written in?
- lucidrains/siren-pytorch is primarily written in Python.
- How popular is siren-pytorch?
- lucidrains/siren-pytorch has 510 stars on GitHub.
- Where can I find siren-pytorch?
- lucidrains/siren-pytorch is on GitHub at https://github.com/lucidrains/siren-pytorch.