Latent space projections
Linear projections
dynax.PODLatentSpace
Proper orthogonal decomposition based latent space.
Linear projections to and from a latent space using the right singular vectors from the SVD of snapshots with as modes/basis.
When projecting into the latent space, the input is first shifted (optional), then scaled and finally projected onto the modes. By default, the scaling is computed such that the latent variables of the snapshots used to calculate the modes have standard deviation one.
For the projection into the full order space, the latent variables are first multiplied with the modes, then scaled and finally shifted.
__init__(snapshots, num_modes, shift=None, scaling='normalize')
Initialize the SVD latent space.
Note
After initialization you can still change the number of modes, i.e., the latent space dimension.
| PARAMETER | DESCRIPTION |
|---|---|
snapshots
|
Snapshots of shape
TYPE:
|
num_modes
|
Number of modes to use in the latent space.
TYPE:
|
shift
|
Array or float to shift a snapshot by, before transforming.
By setting
TYPE:
|
scaling
|
Scalar value to scale all latent variables by.
Can be
TYPE:
|
to_latent(snapshot)
Project snapshot into the latent space.
| PARAMETER | DESCRIPTION |
|---|---|
snapshot
|
Data with shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Shaped[Array, '... n_modes']
|
Array of latent variables with shape |
from_latent(latent_variables)
Project latent variables into the full order space.
| PARAMETER | DESCRIPTION |
|---|---|
latent_variables
|
Data with shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Shaped[Array, '... n_space']
|
Array with shape |
Non-linear projections
dynax.CALMLayer
Continuous and Adaptive convolution Layer.
Implementation of CALM-PDE by Jan Hagnberger, Daniel Musekamp and Mathias Niepert.
__init__(in_channels, out_channels, *, initial_query_points, receptive_size, temperature=1.0, query_points_learnable=True, modulate_kernel=True, initial_input_points=None, num_candidates=None, weight_init=init, bias_init=zeros, rff_init=init, activation=gelu, kernel_activation=gelu, key)
Initialize CALM layer.
| PARAMETER | DESCRIPTION |
|---|---|
in_channels
|
Number of input channels.
TYPE:
|
out_channels
|
Number of output channels.
TYPE:
|
initial_query_points
|
Initial query points array with shape
TYPE:
|
receptive_size
|
Number of points in the input to consider for each query point's receptive field. This is similar to the kernel size in discrete convolutions.
TYPE:
|
temperature
|
Temperature parameter for the softmax function computing the distance weighting. Smaller values increase the weighting of contributions of closer input points for the Monte Carlo integration, while larger values tend to treat all input points equally. Defaults to 1.
TYPE:
|
query_points_learnable
|
Whether query points are learnable. Defaults to True.
TYPE:
|
modulate_kernel
|
Whether to use kernel modulation. Kernel modulation enables the use of different kernel functions per query point, by scaling and shifting the intermediate kernel MLP features with query point specific parameters. Defaults to True.
TYPE:
|
initial_input_points
|
Optional initial input points array with shape
TYPE:
|
num_candidates
|
Number of input point candidates saved for the efficient nearest neighbour computation.
If None, the
TYPE:
|
weight_init
|
Initializer for weights. Defaults to glorot_normal().
TYPE:
|
bias_init
|
Initializer for biases. Defaults to zeros.
TYPE:
|
rff_init
|
Initializer for the random fourier feature (RFF) weight. Defaults to normal(6.0).
TYPE:
|
activation
|
Activation function for the layer output. Defaults to jax.nn.gelu.
TYPE:
|
kernel_activation
|
Activation function for the kernel MLP. Defaults to jax.nn.gelu.
TYPE:
|
key
|
PRNG key for initialization.
TYPE:
|
__call__(x, points, *, key=None)
Compute the continuous convolution output.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input features with shape
TYPE:
|
points
|
Input point coordinates with shape
TYPE:
|
key
|
Unused random key. Defaults to None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[Array, '... m o']
|
Output features for the query point with shape |
Float[Array, 'm d']
|
Query point coordinates with shape |
compute_kernel(rel_pos)
Compute the kernel matrix for a single query point.
| PARAMETER | DESCRIPTION |
|---|---|
rel_pos
|
Relative positions with shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Float[Array, 'm k c o']
|
Kernel matrix with shape |
Helper classes for building CALM-based autoencoders
dynax.PointArgSequential
A sequence of equinox Modules adhering to the PointArgFunc protocol applied in sequence.
This is a modified version of equinox' Sequential.
__init__(layers)
Initialize the PointArgSequential.
| PARAMETER | DESCRIPTION |
|---|---|
layers
|
Sequence of
TYPE:
|
__call__(features, points, /, *, key=None)
Compute the sequential models output.
| PARAMETER | DESCRIPTION |
|---|---|
features
|
Features passed to the first layer.
TYPE:
|
points
|
Points passed to the first layer.
TYPE:
|
key
|
If provided, then it is split by the number of layers, and a subkey passed to each layer.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Array, Array]
|
Output of the last layer, which is a tuple of features and points. |
dynax.PointArgAE
Autoencoder with PointArgFunc encoder and decoder.
__init__(encoder, decoder)
Initialize self. See help(type(self)) for accurate signature.
encode(features, points, /, *, key=None)
decode(features, points, /, *, key=None)
dynax.PointArgWrapper
Wraps a function from features to features to be compatible with the PointArgFunc protocol.
__init__(func)
Initialize self. See help(type(self)) for accurate signature.
__call__(features, points, /, *, key=None)
dynax.PointArgFunc
Function that maps arrays of features and points to features and points.