Embeddings API Reference¶
This module contains input embedding layers for preprocessing data before feeding into the reservoir.
Embedding Base Class¶
EmbedBase ¶
Bases: Module, ABC
Base class dictating API for all implemented embedding layers.
Attributes:
| Name | Type | Description |
|---|---|---|
in_dim |
int
|
Input dimension. |
res_dim |
int
|
Reservoir dimension. |
dtype |
Float
|
Dtype of JAX arrays, jnp.float32 or jnp.float64. |
Methods:
| Name | Description |
|---|---|
embed |
Embed input into reservoir dimension. |
batch_embed |
Embed multiple inputs into reservoir dimension. |
Ensure in dim, res dim, and dtype are correct type.
Source code in src/orc/embeddings.py
embed
abstractmethod
¶
Embed input signal to reservoir dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_state
|
Array
|
Input state, (shape=(in_dim,)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Embedded input state to reservoir dimension. |
Source code in src/orc/embeddings.py
batch_embed ¶
Batch apply embedding from input states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_state
|
Array
|
Input states. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Embedded input states to reservoir, (shape=(batch_dim, res_dim,)). |
Source code in src/orc/embeddings.py
__call__ ¶
Embed state to reservoir dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_state
|
Array
|
Input state, (shape=(in_dim,) or shape=(seq_len, in_dim)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Embedded input to reservoir, (shape=(chunks, res_dim,) or shape=(seq_len, chunks, res_dim)). |
Source code in src/orc/embeddings.py
Linear Embedding¶
ParallelLinearEmbedding ¶
ParallelLinearEmbedding(in_dim: int, res_dim: int, scaling: float, dtype: Float = float64, chunks: int = 1, locality: int = 0, periodic: bool = True, *, seed: int)
Bases: EmbedBase
Linear embedding layer.
Attributes:
| Name | Type | Description |
|---|---|---|
in_dim |
int
|
Reservoir input dimension. |
res_dim |
int
|
Reservoir dimension. |
scaling |
float
|
Min/max values of input matrix. |
win |
Array
|
Input matrix. |
chunks |
int
|
Number of parallel reservoirs. |
locality |
int
|
Adjacent reservoir overlap. |
periodic |
bool
|
Assume periodic BCs when decomposing the input state to parallel network inputs. If False, the input is padded with boundary values at the edges (i.e., edge values are extended to the locality region), which may not match the true spatial dynamics. If True, the input is padded by connecting smoothly the end and beginning of the signal ensuring continuity. Default is True. |
Methods:
| Name | Description |
|---|---|
__call__ |
Embed input state to reservoir dimension. |
localize |
Decompose input_state to parallel network inputs. |
moving_window |
Helper function for localize. |
embed |
Embed single input state to reservoir dimension. |
Instantiate linear embedding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Input dimension to reservoir. |
required |
res_dim
|
int
|
Reservoir dimension. |
required |
scaling
|
float
|
Min/max values of input matrix. |
required |
seed
|
int
|
Random seed for generating the PRNG key for the reservoir computer. |
required |
dtype
|
Float
|
Dtype of model, jnp.float64 or jnp.float32. |
float64
|
periodic
|
bool
|
Assume periodic BCs when decomposing the input state to parallel network inputs. If False, the input is padded with boundary values at the edges (i.e., edge values are extended to the locality region), which may not match the true spatial dynamics. If True, the input is padded by connecting smoothly the end and beginning of the signal ensuring continuity. Default is True. |
True
|
Source code in src/orc/embeddings.py
moving_window ¶
Generate window to compute localized states.
Source code in src/orc/embeddings.py
localize ¶
Generate parallel reservoir inputs from input state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_state
|
Array
|
Input state, (shape=(in_dim,)) |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Parallel reservoir inputs, (shape=(chunks, chunk_size + 2*locality)) |
Source code in src/orc/embeddings.py
embed ¶
Embed single state to reservoir dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_state
|
Array
|
Input state, (shape=(in_dim,)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Embedded input to reservoir, (shape=(chunks, res_dim,)). |