superstats.networks#

Neural network components for superstats workflows.

class superstats.networks.RecurrentNet(*args, **kwargs)[source]#

Bases: SummaryNetwork

Implements a sequence-producing recurrent network.

Parameters:
summary_dimint, optional, default: 64

Per-timestep output dimensionality.

hidden_dimint or sequence of int, optional, default: (128, 128)

Dimensionality of the hidden state in each recurrent layer.

recurrent_type{“lstm”, “gru”} or sequence, optional, default: “lstm”

Type of recurrent unit to use in each layer.

bidirectionalbool or sequence of bool, optional, default: True

If True, the layer is processed bidirectionally and the two directions are merged according to merge_mode. If False, the layer processes the sequence forward only.

merge_mode{“sum”, “mul”, “ave”, “concat”} or sequence, optional, default: “sum”

Mode used to merge forward and backward outputs in bidirectional layers.

layer_normbool or sequence of bool, optional, default: True

Whether to apply layer normalization after each recurrent layer.

time_embed_dimint, optional, default: 16

The number of features learned by the time2vec preprocessing layer.

dropoutfloat or sequence of float in [0, 1], optional, default: 0.05

Dropout rate applied after the recurrent layer(s).

**kwargs

Additional keyword arguments passed to the parent class constructor.

Raises:
ValueError

If per-layer parameter sequences have incompatible lengths or contain invalid values.

Parameters:

Notes

All recurrent layers are built with return_sequences=True, so the projection is applied per timestep and the sequence-length axis is retained. If any of hidden_dim, recurrent_type, bidirectional, merge_mode, or layer_norm is a sequence with more than one element, all single values are expanded to that length. Multiple multi-element sequences must have the same length.

call(time_series, training=False)[source]#

Compute per-timestep summary statistics for a batch of time series.

Parameters:
time_seriesTensor of shape (batch_size, sequence_length, num_features)

Input time series.

trainingbool, optional, default: False

Whether the layer is in training mode (affects dropout).

Returns:
summaryTensor - the learned summary of shape

(batch_size, sequence_length, summary_dim).

Parameters:
  • time_series (Tensor)

  • training (bool)

Return type:

Tensor

get_config()[source]#

Returns the config of the object.

An object config is a Python dictionary (serializable) containing the information needed to re-instantiate it.

Modules

recurrent

Recurrent summary network layers.

utils

Utility functions for network configuration.