phygnn.layers.custom_layers

Custom tf layers.

Functions

get_custom_layer_objects()

Get local custom layer classes for Keras deserialization.

Classes

CBAM(*args, **kwargs)

Convolutional Block Attention Module

ExpandDims(*args, **kwargs)

Layer to add an extra dimension to a tensor.

FlattenAxis(*args, **kwargs)

Layer to flatten an axis from a 5D spatiotemporal Tensor into axis-0 observations.

FlexiblePadding(*args, **kwargs)

Class to perform padding on tensors

FunctionalLayer(*args, **kwargs)

Custom layer to implement the tensorflow layer functions (e.g., add, subtract, multiply, maximum, and minimum) with a constant value.

GaussianAveragePooling2D(*args, **kwargs)

Custom layer to implement tensorflow average pooling layer but with a gaussian kernel.

GaussianNoiseAxis(*args, **kwargs)

Layer to apply random noise along a given axis.

LogTransform(*args, **kwargs)

Log transform or inverse transform of data

MaskedSqueezeAndExcitation(*args, **kwargs)

Custom layer for masked squeeze and excitation block for convolutional networks

MultiHeadAttention(*args, **kwargs)

MultiHeadAttention that accepts an additive pre-softmax bias.

PatchDecoder(*args, **kwargs)

Project token features back to the query feature grid.

PatchEncoder(*args, **kwargs)

Project spatial inputs into token features.

PositionEncoder(*args, **kwargs)

Positional encoding layer.

SigLin(*args, **kwargs)

Sigmoid linear unit.

SkipConnection(*args, **kwargs)

Custom layer to implement a skip connection.

SpatialExpansion(*args, **kwargs)

Class to expand the spatial dimensions of tensors with shape: (n_observations, n_spatial_0, n_spatial_1, n_features)

SpatioTemporalExpansion(*args, **kwargs)

Class to expand the spatiotemporal dimensions of tensors with shape: (n_observations, n_spatial_0, n_spatial_1, n_temporal, n_features)

SqueezeAndExcitation(*args, **kwargs)

Custom layer for squeeze and excitation block for convolutional networks

Sup3rAdder(*args, **kwargs)

Layer to add high-resolution data to a sup3r model in the middle of a super resolution forward pass.

Sup3rConcat(*args, **kwargs)

Layer to concatenate a high-resolution feature to a sup3r model in the middle of a super resolution forward pass.

Sup3rConcatObs(*args, **kwargs)

Layer to concatenate sparse data in the middle of a super resolution forward pass.

Sup3rObsModel(*args, **kwargs)

Layer to concatenate sparse data in the middle of a super resolution forward pass, with a learned embedding.

Sup3rTransformerBlock(*args, **kwargs)

Stack of Sup3rTransformerLayer instances with optional window shifting on odd layers in the stack.

Sup3rTransformerLayer(*args, **kwargs)

Transformer layer with shared Q encoding, joint K/V attention, and a shared post-attention pathway.

SwiGLU(*args, **kwargs)

SwiGLU activation function.

TileLayer(*args, **kwargs)

Layer to tile (repeat) data across a given axis.

TransformerLayer(*args, **kwargs)

Custom transformer layer with multi-head attention layer that allows for additive bias pre-softmax.

UnitConversion(*args, **kwargs)

Layer to convert units per feature channel using the linear transform: y = x * scalar + adder

WindowGeometry(batch_size, query_height, ...)

Computed layout for one windowed-attention call.

WindowedMultiHeadAttention(*args, **kwargs)

MultiHeadAttention with overlapping spatial windowing.