{
  "$schema": "https://ambiqai.github.io/helia-ui/schema/reference-model-1.json",
  "generatedFrom": {
    "sourceCommit": "f341fb11f7f5d77a4974ba8273c4cd55d67c21f0",
    "tool": "pyref",
    "version": "1.7.3"
  },
  "language": "python",
  "modules": [
    {
      "description": "# Temporal Convolutional Network (TCN)\n\n## Overview\n\nTemporal convolutional network (TCN) is a type of convolutional neural network (CNN) that is commonly used for sequence modeling tasks such as speech recognition, text generation, and video classification. TCN is a fully convolutional network that consists of a series of dilated causal convolutional layers. The dilated convolutional layers allow TCN to have a large receptive field while maintaining a small number of parameters. TCN is also fully parallelizable, which allows for faster training and inference times.\n\nFor more info, refer to the original paper [Temporal Convolutional Networks: A Unified Approach to Action Segmentation](https://doi.org/10.48550/arXiv.1608.08242).\n\nParameters are in ``helia_edge.models.tcn_params``.\n\n**Functions**\n\n| Name | Description |\n| --- | --- |\n| `build` | TCN model from ``TcnParams`` |\n| `normalization` | Normalization layer |\n| `tcn_block_lg` | TCN large block |\n| `tcn_block_mb` | TCN mbconv block |\n| `tcn_block_sm` | TCN small block |\n| `tcn_core` | TCN core |\n| `tcn_layer` | TCN functional layer |\n\n## Additions\n\nThe TCN architecture has been modified to allow the following:\n\n* Convolutional pairs can be factorized into depthwise separable convolutions.\n* Squeeze and excitation (SE) blocks can be added between convolutional pairs.\n* Normalization can be set between batch normalization and layer normalization.\n* ReLU is replaced with the approximated ReLU6.\n\n## Usage\n\nThe following example builds a TCN from `TcnParams` and `TcnBlockParams` through a `ModelSpec`.\n\n```python\nimport helia_edge as helia\n\nparams = helia.models.TcnParams(\n    input_kernel=(1, 3),\n    input_norm=\"batch\",\n    blocks=[\n        helia.models.TcnBlockParams(filters=8, kernel=(1, 3), dilation=(1, 1), dropout=0.1, ex_ratio=1, se_ratio=0, norm=\"batch\"),\n        helia.models.TcnBlockParams(filters=16, kernel=(1, 3), dilation=(1, 2), dropout=0.1, ex_ratio=1, se_ratio=0, norm=\"batch\"),\n        helia.models.TcnBlockParams(filters=24, kernel=(1, 3), dilation=(1, 4), dropout=0.1, ex_ratio=1, se_ratio=4, norm=\"batch\"),\n        helia.models.TcnBlockParams(filters=32, kernel=(1, 3), dilation=(1, 8), dropout=0.1, ex_ratio=1, se_ratio=4, norm=\"batch\"),\n    ],\n    output_kernel=(1, 3),\n    include_top=True,\n    num_classes=5,\n    use_logits=True,\n)\nmodel = helia.models.build(helia.models.ModelSpec(params=params, input_shape=(1, 800, 1)))\n```",
      "name": "tcn",
      "path": "helia_edge.models.tcn",
      "submodules": [],
      "summary": "Temporal Convolutional Network (TCN)",
      "symbols": [
        {
          "description": "Normalization layer",
          "examples": [],
          "id": "helia_edge.models.tcn.normalization",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "normalization",
          "params": [
            {
              "description": "Normalization type",
              "name": "norm",
              "type": "str"
            },
            {
              "description": "Name",
              "name": "name",
              "type": "str"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Layer: Layer",
              "type": "keras.Layer"
            }
          ],
          "signature": "normalization(norm: str, name: str) -> keras.Layer",
          "source": {
            "line": 63,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L63"
          },
          "summary": "Normalization layer"
        },
        {
          "description": "TCN large block",
          "examples": [],
          "id": "helia_edge.models.tcn.tcn_block_lg",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "tcn_block_lg",
          "params": [
            {
              "description": "Parameters",
              "name": "params",
              "type": "TcnBlockParams"
            },
            {
              "description": "Name",
              "name": "name",
              "type": "str"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Layer: Layer",
              "type": "keras.Layer"
            }
          ],
          "signature": "tcn_block_lg(params: TcnBlockParams, name: str) -> keras.Layer",
          "source": {
            "line": 92,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L92"
          },
          "summary": "TCN large block"
        },
        {
          "description": "TCN mbconv block",
          "examples": [],
          "id": "helia_edge.models.tcn.tcn_block_mb",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "tcn_block_mb",
          "params": [
            {
              "description": "Parameters",
              "name": "params",
              "type": "TcnBlockParams"
            },
            {
              "description": "Name",
              "name": "name",
              "type": "str"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Layer: Layer",
              "type": "keras.Layer"
            }
          ],
          "signature": "tcn_block_mb(params: TcnBlockParams, name: str) -> keras.Layer",
          "source": {
            "line": 157,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L157"
          },
          "summary": "TCN mbconv block"
        },
        {
          "description": "TCN small block",
          "examples": [],
          "id": "helia_edge.models.tcn.tcn_block_sm",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "tcn_block_sm",
          "params": [
            {
              "description": "Parameters",
              "name": "params",
              "type": "TcnBlockParams"
            },
            {
              "description": "Name",
              "name": "name",
              "type": "str"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Layer: Layer",
              "type": "keras.Layer"
            }
          ],
          "signature": "tcn_block_sm(params: TcnBlockParams, name: str) -> keras.Layer",
          "source": {
            "line": 258,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L258"
          },
          "summary": "TCN small block"
        },
        {
          "description": "TCN core",
          "examples": [],
          "id": "helia_edge.models.tcn.tcn_core",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "tcn_core",
          "params": [
            {
              "description": "Parameters",
              "name": "params",
              "type": "TcnParams"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Layer: Layer",
              "type": "keras.Layer"
            }
          ],
          "signature": "tcn_core(params: TcnParams) -> keras.Layer",
          "source": {
            "line": 344,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L344"
          },
          "summary": "TCN core"
        },
        {
          "description": "TCN functional layer",
          "examples": [],
          "id": "helia_edge.models.tcn.tcn_layer",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "tcn_layer",
          "params": [
            {
              "description": "Input tensor",
              "name": "x",
              "type": "keras.KerasTensor"
            },
            {
              "description": "Parameters",
              "name": "params",
              "type": "TcnParams"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.KerasTensor: Output tensor",
              "type": "keras.KerasTensor"
            }
          ],
          "signature": "tcn_layer(x: keras.KerasTensor, params: TcnParams) -> keras.KerasTensor",
          "source": {
            "line": 373,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L373"
          },
          "summary": "TCN functional layer"
        },
        {
          "description": "Build a TCN model.",
          "examples": [],
          "id": "helia_edge.models.tcn.build",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "build",
          "params": [
            {
              "description": "Model parameters.",
              "name": "params",
              "type": "TcnParams"
            },
            {
              "description": "Input shape without the batch axis; None for a variable axis.",
              "name": "input_shape",
              "type": "tuple[int | None, ...]"
            },
            {
              "default": "None",
              "description": "Static batch size; None for a dynamic batch.",
              "name": "batch_size",
              "type": "int | None"
            },
            {
              "default": "None",
              "description": "Model name; the family when None.",
              "name": "name",
              "type": "str | None"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Model: The model, named ``tcn`` unless ``name`` is given.",
              "type": "keras.Model"
            }
          ],
          "signature": "build(\n    params: TcnParams,\n    input_shape: tuple[int | None, ...],\n    *,\n    batch_size: int | None = None,\n    name: str | None = None,\n) -> keras.Model",
          "source": {
            "line": 428,
            "path": "helia_edge/models/tcn.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/tcn.py#L428"
          },
          "summary": "Build a TCN model."
        }
      ]
    }
  ],
  "name": "helia_edge"
}
