# helia_edge.layers.streaming

## Streaming Layers API

Recurrent cells for streaming models whose state is an explicit model input and output. One model call
processes one step: the caller feeds each ``state_out_k`` output back as the ``state_in_k`` input of the next
call, and feeds zeros at the start of an independent sequence.

**Classes**

| Name | Description |
| --- | --- |
| `StreamingLSTMCell` | One LSTM step with explicit hidden and cell state |

**Functions**

| Name | Description |
| --- | --- |
| `state_input` | Model input for state pair ``k`` |
| `state_output` | Model output for state pair ``k`` |

## helia_edge.layers.streaming.StreamingLSTMCell

`class` · `python`

```python
StreamingLSTMCell(units: int, use_bias: bool = True, unit_forget_bias: bool = True, **kwargs={})
```

One LSTM step: ``[x, h, c] -> [h', c']``.

The weights have the layout of ``keras.layers.LSTMCell``: ``kernel`` (features, 4 * units),
``recurrent_kernel`` (units, 4 * units) and ``bias`` (4 * units), with gates in the order input,
forget, cell, output. Weights of a ``keras.layers.LSTM`` or ``LSTMCell`` load unchanged.

c' = f * c + i * tanh(z_c) and h' = o * tanh(c'), where z = x W + h R + b and i, f, o are the sigmoid
of their slices of z.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| units | int | Required | Size of the hidden and cell state. |
| use_bias | bool | True | Add ``bias`` to the gates. |
| unit_forget_bias | bool | True | Initialize the forget gate's bias to one and the others to zero, as ``keras.layers.LSTMCell`` does. |

Source: `helia_edge/layers/streaming.py:22`

### helia_edge.layers.streaming.StreamingLSTMCell.units

`attribute` · `python`

```python
units = units
```

Source: `helia_edge/layers/streaming.py:42`

### helia_edge.layers.streaming.StreamingLSTMCell.use_bias

`attribute` · `python`

```python
use_bias = use_bias
```

Source: `helia_edge/layers/streaming.py:43`

### helia_edge.layers.streaming.StreamingLSTMCell.unit_forget_bias

`attribute` · `python`

```python
unit_forget_bias = unit_forget_bias
```

Source: `helia_edge/layers/streaming.py:44`

### helia_edge.layers.streaming.StreamingLSTMCell.build

`method` · `python`

```python
build(input_shape)
```

Source: `helia_edge/layers/streaming.py:46`

### helia_edge.layers.streaming.StreamingLSTMCell.call

`method` · `python`

```python
call(inputs)
```

Source: `helia_edge/layers/streaming.py:66`

### helia_edge.layers.streaming.StreamingLSTMCell.compute_output_shape

`method` · `python`

```python
compute_output_shape(input_shape)
```

Source: `helia_edge/layers/streaming.py:79`

### helia_edge.layers.streaming.StreamingLSTMCell.get_config

`method` · `python`

```python
get_config()
```

Source: `helia_edge/layers/streaming.py:83`

## helia_edge.layers.streaming.state_input

`function` · `python`

```python
state_input(k: int, shape: tuple[int, ...], batch_size: int | None = None) -> keras.KerasTensor
```

Model input ``state_in_k`` for state pair ``k``.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| k | int | Required | State pair index; ``state_out_k`` is the matching output. |
| shape | tuple[int, ...] | Required | State shape without the batch dimension. |
| batch_size | int \| None | None | Fixed batch size, or None. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.KerasTensor | keras.KerasTensor: The input tensor. |

Source: `helia_edge/layers/streaming.py:92`

## helia_edge.layers.streaming.state_output

`function` · `python`

```python
state_output(k: int, x: keras.KerasTensor) -> keras.KerasTensor
```

Name ``x`` as the model output ``state_out_k`` of state pair ``k``.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| k | int | Required | State pair index; ``state_in_k`` is the matching input. |
| x | keras.KerasTensor | Required | The next state. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.KerasTensor | keras.KerasTensor: ``x`` through an identity layer named ``state_out_k``. |

Source: `helia_edge/layers/streaming.py:106`
