{
  "$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": "# U-Net\n\n## Overview\n\nU-Net is a type of convolutional neural network (CNN) that is commonly used for segmentation tasks. U-Net 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 U-Net to preserve spatial/temporal information while also allowing for faster training and inference times.\n\nFor more info, refer to the original paper [U-Net: Convolutional Networks for Biomedical Image Segmentation](https://doi.org/10.1007/978-3-319-24574-4_28).\n\nParameters are in ``helia_edge.models.unet_params``.\n\n**Functions**\n\n| Name | Description |\n| --- | --- |\n| `build` | U-Net model from ``UNetParams`` |\n| `unet_layer` | Generate functional U-Net model |\n\n## Additions\n\nThe U-Net architecture has been modified to allow the following:\n\n* Enable 1D and 2D variants.\n* Convolutional pairs can factorized into depthwise separable convolutions.\n* Specifiy the number of convolutional layers per block both downstream and upstream.\n* Normalization can be set between batch normalization and layer normalization.\n* ReLU is replaced with the approximated ReLU6.\n\n## Usage\n\n```python\nfrom helia_edge.models import ModelSpec, UNetBlockParams, UNetParams, build\n\nblock = dict(depth=2, ddepth=1, kernel=(1, 5), pool=(1, 3), strides=(1, 2), skip=True, seperable=True)\nparams = UNetParams(\n    blocks=[UNetBlockParams(filters=f, **block) for f in (12, 24, 32, 48)],\n    output_kernel_size=(1, 5),\n    include_top=True,\n    use_logits=True,\n    num_classes=5,\n)\nmodel = build(ModelSpec(params=params, input_shape=(1, 800, 1)))\n```",
      "name": "unet",
      "path": "helia_edge.models.unet",
      "submodules": [],
      "summary": "U-Net",
      "symbols": [
        {
          "description": "Create UNet TF functional model",
          "examples": [],
          "id": "helia_edge.models.unet.unet_layer",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "unet_layer",
          "params": [
            {
              "description": "Input tensor",
              "name": "x",
              "type": "keras.KerasTensor"
            },
            {
              "description": "Model parameters.",
              "name": "params",
              "type": "UNetParams"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.KerasTensor: Output tensor",
              "type": "keras.KerasTensor"
            }
          ],
          "signature": "unet_layer(x: keras.KerasTensor, params: UNetParams) -> keras.KerasTensor",
          "source": {
            "line": 51,
            "path": "helia_edge/models/unet.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/unet.py#L51"
          },
          "summary": "Create UNet TF functional model"
        },
        {
          "description": "Build a UNet model.",
          "examples": [],
          "id": "helia_edge.models.unet.build",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "build",
          "params": [
            {
              "description": "Model parameters.",
              "name": "params",
              "type": "UNetParams"
            },
            {
              "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 ``unet`` unless ``name`` is given.",
              "type": "keras.Model"
            }
          ],
          "signature": "build(\n    params: UNetParams,\n    input_shape: tuple[int | None, ...],\n    *,\n    batch_size: int | None = None,\n    name: str | None = None,\n) -> keras.Model",
          "source": {
            "line": 264,
            "path": "helia_edge/models/unet.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/unet.py#L264"
          },
          "summary": "Build a UNet model."
        }
      ]
    }
  ],
  "name": "helia_edge"
}
