Readouts API Reference¶
This module contains readout layers that map reservoir states to outputs.
Readout Base Class¶
ReadoutBase ¶
Bases: Module, ABC
Base class dictating API for all implemented readout layers.
Attributes:
| Name | Type | Description |
|---|---|---|
out_dim |
int
|
Dimension of reservoir output. |
res_dim |
int
|
Reservoir dimension. |
dtype |
Float
|
Dtype of JAX arrays, jnp.float32 or jnp.float64. |
Methods:
| Name | Description |
|---|---|
readout |
Map from reservoir state to output state. |
batch_readout |
Map from reservoir states to output states. |
Ensure in dim, res dim, and dtype are correct type.
Source code in src/orc/readouts.py
readout
abstractmethod
¶
Readout from reservoir state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Output from reservoir state. |
Source code in src/orc/readouts.py
batch_readout ¶
Batch apply readout from reservoir states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Output from reservoir states. |
Source code in src/orc/readouts.py
__call__ ¶
Call either readout or batch_readout depending on dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state, (shape=(chunks, res_dim) or shape=(seq_len, chunks, res_dim)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Output state, (out_dim,) or shape=(seq_len, out_dim)). |
Source code in src/orc/readouts.py
Linear Readout¶
ParallelLinearReadout ¶
ParallelLinearReadout(out_dim: int, res_dim: int, chunks: int = 1, dtype: Float = float64, *, seed: int = 0)
Bases: ReadoutBase
Linear readout layer.
Attributes:
| Name | Type | Description |
|---|---|---|
out_dim |
int
|
Dimension of reservoir output. |
res_dim |
int
|
Reservoir dimension. |
chunks |
int
|
Number of parallel reservoirs. |
wout |
Array
|
Output matrix. |
dtype |
Float
|
Dtype, default jnp.float64. |
Methods:
| Name | Description |
|---|---|
readout |
Map from reservoir state to output state. |
Initialize readout layer to zeros.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dim
|
int
|
Dimension of reservoir output. |
required |
res_dim
|
int
|
Reservoir dimension. |
required |
chunks
|
int
|
Number of parallel resrevoirs. |
1
|
dtype
|
Float
|
Dtype, default jnp.float64. |
float64
|
seed
|
int
|
Not used for ParallelLinearReadout, here to maintain consistent interface. |
0
|
Source code in src/orc/readouts.py
readout ¶
Readout from reservoir state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state, (shape=(chunks, res_dim,)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Output from reservoir, (shape=(out_dim,)). |
Source code in src/orc/readouts.py
Nonlinear Readout¶
ParallelNonlinearReadout ¶
ParallelNonlinearReadout(out_dim: int, res_dim: int, nonlin_list: list[Callable], chunks: int = 1, dtype: Float = float64, *, seed: int = 0)
Bases: ReadoutBase
Readout layer with user specified nonlinearities.
Attributes:
| Name | Type | Description |
|---|---|---|
out_dim |
int
|
Dimension of reservoir output. |
res_dim |
int
|
Reservoir dimension. |
chunks |
int
|
Number of parallel reservoirs. |
wout |
Array
|
Output matrix. |
nonlin_list |
list
|
List containing user specified nonlinearities. |
dtype |
Float
|
Dtype, default jnp.float64. |
Methods:
| Name | Description |
|---|---|
nonlinear_transform |
Nonlinear transform that acts entrywise on reservoir state. |
readout |
Map from reservoir state to output state. |
__call__ |
Map from reservoir state to output state, handles batch and single outputs. |
Initialize readout layer to zeros.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dim
|
int
|
Dimension of reservoir output. |
required |
res_dim
|
int
|
Reservoir dimension. |
required |
nonlin_list
|
list[Callable]
|
List containing user specified entrywise nonlinearities. Each entry should be a function mapping a scalar value to another scalar value, e.g. lambda x : x ** 2 or lambda x : jnp.sin(x). |
required |
chunks
|
int
|
Number of parallel reservoirs. |
1
|
dtype
|
Float
|
Dtype, default jnp.float64. |
float64
|
seed
|
int
|
Not used for ParallelNonlinearReadout, here to maintain consistent interface. |
0
|
Source code in src/orc/readouts.py
nonlinear_transform ¶
Perform nonlinear transformation on reservoir state.
Let tot_list be the list consisting of nonlin_list prepended by the identity mapping. Let n be the length of tot_list. Then, nonlinear_transform acts such that for all 0 <= k < chunks and 0 <= j < j * n: res_state[k, j * n] <- res_state[k, j*n] res_state[k, j * n + 1] <- f_0(res_state[k, j * n + 1]) ... res_state[k, j * n + n - 1] <- f_{n-1}(res_state[k, j * n + n - 1]) where f_i is the i-th entry of nonlin_list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state, (shape=(..., res_dim,)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Transformed reservoir state. |
Source code in src/orc/readouts.py
readout ¶
Readout from reservoir state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_state
|
Array
|
Reservoir state, (shape=(chunks, res_dim,)). |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Output from reservoir, (shape=(out_dim,)). |
Source code in src/orc/readouts.py
Quadratic Readout¶
ParallelQuadraticReadout ¶
ParallelQuadraticReadout(out_dim: int, res_dim: int, chunks: int = 1, dtype: Float = float64, *, seed: int = 0)
Bases: ParallelNonlinearReadout
Quadratic readout layer.
Attributes:
| Name | Type | Description |
|---|---|---|
out_dim |
int
|
Dimension of reservoir output. |
res_dim |
int
|
Reservoir dimension. |
chunks |
int
|
Number of parallel reservoirs. |
wout |
Array
|
Output matrix. |
dtype |
Float
|
Dtype, default jnp.float64. |
Methods:
| Name | Description |
|---|---|
nonlinear_transform |
Quadratic transform that acts entrywise on reservoir state. |
readout |
Map from reservoir state to output state with quadratic nonlinearity. |
__call__ |
Map from reservoir state to output state with quadratic nonlinearity, handles batch and single outputs. |
Initialize readout layer to zeros.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dim
|
int
|
Dimension of reservoir output. |
required |
res_dim
|
int
|
Reservoir dimension. |
required |
chunks
|
int
|
Number of parallel resrevoirs. |
1
|
dtype
|
Float
|
Dtype, default jnp.float64. |
float64
|
seed
|
int
|
Not used for ParallelQuadraticReadout, here to maintain consistent interface. |
0
|