Surrogate Networks API Reference
Neural networks that learn to predict PSFs from lens parameters, replacing expensive ray tracing during training.
deeplens.surrogate.MLP
Bases: Module
Fully-connected network for low-frequency PSF prediction.
Predicts PSFs as flattened vectors using stacked linear layers with ReLU activations and a Sigmoid output. The output is L1-normalized so it sums to 1 (valid as a PSF energy distribution).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_features
|
Number of input features (e.g., field angle + wavelength). |
required | |
out_features
|
Number of output features (flattened PSF size). |
required | |
hidden_features
|
Width of hidden layers. Defaults to 64. |
64
|
|
hidden_layers
|
Number of hidden layers. Defaults to 3. |
3
|
Source code in deeplens/surrogate/mlp.py
forward
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Input tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
|
L1-normalized output tensor of shape |
Source code in deeplens/surrogate/mlp.py
deeplens.surrogate.MLPConv
Bases: Module
MLP encoder + convolutional decoder for high-resolution PSF prediction.
Uses a linear encoder to produce a low-resolution feature map, then a transposed-convolution decoder to upsample to the target PSF resolution. The output is Sigmoid-activated and L1-normalized per spatial dimension.
Reference: "Differentiable Compound Optics and Processing Pipeline Optimization for End-To-end Camera Design".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_features
|
Number of input features (e.g., field angle + wavelength). |
required | |
ks
|
Spatial size of the output PSF. Must be a multiple of 32 if > 32. |
required | |
channels
|
Number of output channels. Defaults to 3. |
3
|
|
activation
|
Activation function, |
'relu'
|
Source code in deeplens/surrogate/mlpconv.py
forward
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Input tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
|
Normalized PSF tensor of shape |
Source code in deeplens/surrogate/mlpconv.py
deeplens.surrogate.siren.Siren
Bases: Module
Single SIREN (Sinusoidal Representation Network) layer.
A linear layer followed by a sine activation. Uses the initialization scheme from "Implicit Neural Representations with Periodic Activation Functions".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim_in
|
Input dimension. |
required | |
dim_out
|
Output dimension. |
required | |
w0
|
Frequency multiplier for the sine activation. Defaults to 1.0. |
1.0
|
|
c
|
Constant for weight initialization. Defaults to 6.0. |
6.0
|
|
is_first
|
Whether this is the first layer (uses different init). Defaults to False. |
False
|
|
use_bias
|
Whether to include a bias term. Defaults to True. |
True
|
|
activation
|
Custom activation module. If None, uses |
None
|
Source code in deeplens/surrogate/siren.py
forward
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Input tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
|
Output tensor of shape |
Source code in deeplens/surrogate/siren.py
deeplens.surrogate.ModulateSiren
ModulateSiren(dim_in, dim_hidden, dim_out, dim_latent, num_layers, image_width, image_height, w0=1.0, w0_initial=30.0, use_bias=True, final_activation=None, outermost_linear=True)
Bases: Module
Modulated SIREN for latent-conditioned image synthesis.
Combines a SIREN synthesizer network (mapping pixel coordinates to output values) with a modulator network that conditions each layer based on a latent vector. Used to predict spatially-varying PSFs conditioned on lens parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim_in
|
Input coordinate dimension (typically 2 for x, y). |
required | |
dim_hidden
|
Hidden layer width for both synthesizer and modulator. |
required | |
dim_out
|
Output dimension per pixel (e.g., 1 for grayscale PSF). |
required | |
dim_latent
|
Dimension of the conditioning latent vector. |
required | |
num_layers
|
Number of SIREN + modulator layers. |
required | |
image_width
|
Output image width in pixels. |
required | |
image_height
|
Output image height in pixels. |
required | |
w0
|
Frequency multiplier for hidden sine layers. Defaults to 1.0. |
1.0
|
|
w0_initial
|
Frequency multiplier for the first sine layer. Defaults to 30.0. |
30.0
|
|
use_bias
|
Whether to use bias in sine layers. Defaults to True. |
True
|
|
final_activation
|
Activation for the last layer. Defaults to None (linear). |
None
|
|
outermost_linear
|
If True, the last layer is a plain linear layer. Defaults to True. |
True
|
Source code in deeplens/surrogate/modulate_siren.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
forward
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent
|
Conditioning latent vector of shape |
required |
Returns:
| Type | Description |
|---|---|
|
Output image tensor of shape |