# helia_edge.models.resnet

## ResNet

### Overview

ResNet is a type of convolutional neural network (CNN) that is commonly used for image classification tasks. ResNet is a fully convolutional network that consists of a series of convolutional layers and pooling layers. The pooling layers are used to downsample the input while the convolutional layers are used to upsample the input. The skip connections between the pooling layers and convolutional layers allow ResNet to preserve spatial/temporal information while also allowing for faster training and inference times.

For more info, refer to the original paper [Deep Residual Learning for Image Recognition](https://doi.org/10.1109/CVPR.2016.90).

Parameters are in ``helia_edge.models.resnet_params``.

**Functions**

| Name | Description |
| --- | --- |
| `build` | ResNet model from ``ResNetParams`` |
| `generate_bottleneck_block` | Generate functional bottleneck block |
| `generate_residual_block` | Generate functional residual block |
| `resnet_layer` | Generate functional ResNet model |

### Additions

* Enable 1D and 2D variants.

## helia_edge.models.resnet.generate_bottleneck_block

`function` · `python`

```python
generate_bottleneck_block(
    filters: int,
    kernel_size: int | tuple[int, int] = 3,
    strides: int | tuple[int, int] = 1,
    expansion: int = 4,
    activation: str = 'relu6',
) -> keras.Layer
```

Generate functional bottleneck block.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| filters | int | Required | Filter size |
| kernel_size | int \| tuple[int, int] | 3 | Kernel size. Defaults to 3. |
| strides | int \| tuple[int, int] | 1 | Stride length. Defaults to 1. |
| expansion | int | 4 | Expansion factor. Defaults to 4. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.Layer | keras.Layer: TF functional layer |

Source: `helia_edge/models/resnet.py:31`

## helia_edge.models.resnet.generate_residual_block

`function` · `python`

```python
generate_residual_block(
    filters: int,
    kernel_size: int | tuple[int, int] = 3,
    strides: int | tuple[int, int] = 1,
    activation: str = 'relu6',
) -> keras.Layer
```

Generate functional residual block

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| filters | int | Required | Filter size |
| kernel_size | int \| tuple[int, int] | 3 | Kernel size. Defaults to 3. |
| strides | int \| tuple[int, int] | 1 | Stride length. Defaults to 1. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.Layer | keras.Layer: TF functional layer |

Source: `helia_edge/models/resnet.py:75`

## helia_edge.models.resnet.resnet_layer

`function` · `python`

```python
resnet_layer(x: keras.KerasTensor, params: ResNetParams) -> keras.KerasTensor
```

Generate functional ResNet model.
Args:
    x (keras.KerasTensor): Inputs
    params (ResNetParams): Model parameters.

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.KerasTensor | keras.KerasTensor: Output tensor |

Source: `helia_edge/models/resnet.py:111`

## helia_edge.models.resnet.build

`function` · `python`

```python
build(
    params: ResNetParams,
    input_shape: tuple[int | None, ...],
    *,
    batch_size: int | None = None,
    name: str | None = None,
) -> keras.Model
```

Build a ResNet model.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| params | ResNetParams | Required | Model parameters. |
| input_shape | tuple[int \| None, ...] | Required | Input shape without the batch axis; None for a variable axis. |
| batch_size | int \| None | None | Static batch size; None for a dynamic batch. |
| name | str \| None | None | Model name; the family when None. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | keras.Model | keras.Model: The model, named ``resnet`` unless ``name`` is given. |

Source: `helia_edge/models/resnet.py:169`
