{
  "$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": "# Model utilities API\n\nThis module provides utility functions to work with Keras models.\n\n**Functions**\n\n| Name | Description |\n| --- | --- |\n| `make_divisible` | Ensure layer has # channels divisble by divisor |\n| `load_model` | Loads a Keras model stored either remotely or locally |\n| `append_layers` | Appends layers to a model by cloning it and adding the layers |",
      "name": "utils",
      "path": "helia_edge.models.utils",
      "submodules": [],
      "summary": "Model utilities API",
      "symbols": [
        {
          "description": "Ensure layer has # channels divisble by divisor\n   https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py",
          "examples": [],
          "id": "helia_edge.models.utils.make_divisible",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "make_divisible",
          "params": [
            {
              "description": "Number of channels",
              "name": "v",
              "type": "int"
            },
            {
              "default": "4",
              "description": "Divisor. Defaults to 4.",
              "name": "divisor",
              "type": "int"
            },
            {
              "default": "None",
              "description": "Min # channels. Defaults to None.",
              "name": "min_value",
              "type": "int | None"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "Number of channels",
              "name": "int",
              "type": "int"
            }
          ],
          "signature": "make_divisible(v: int, divisor: int = 4, min_value: int | None = None) -> int",
          "source": {
            "line": 28,
            "path": "helia_edge/models/utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/utils.py#L28"
          },
          "summary": "Ensure layer has # channels divisble by divisor https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py"
        },
        {
          "description": "Rename layers whose names contain ``.`` in a saved Keras model config.\n\nTorch registers each layer as a module attribute, and attribute names cannot contain ``.``.\nEvery layer-like entry is renamed, including the model itself and any named loss or metric\nobjects, so a name in any of them can trigger the collision check.\nEach ``.`` becomes ``_``. Layer names, connections (``keras_history``), the model's input\nand output lists, and the output-name keys of ``compile_config`` (losses, metrics, loss\nweights) are renamed together; weights are stored by structure, not by name, so they need no\nchange.",
          "examples": [],
          "id": "helia_edge.models.utils.undot_layer_names",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "undot_layer_names",
          "params": [
            {
              "description": "The parsed ``config.json`` of a ``.keras`` file.",
              "name": "config",
              "type": "Any"
            }
          ],
          "raises": [
            {
              "description": "If a new name equals another layer's name.",
              "type": "ValueError"
            }
          ],
          "returns": [
            {
              "description": "The renamed config (a new object) and the mapping from old to new names.",
              "name": "tuple",
              "type": "tuple[Any, dict[str, str]]"
            }
          ],
          "signature": "undot_layer_names(config: Any) -> tuple[Any, dict[str, str]]",
          "source": {
            "line": 49,
            "path": "helia_edge/models/utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/utils.py#L49"
          },
          "summary": "Rename layers whose names contain ."
        },
        {
          "description": "Swap Keras ``LayerNormalization`` entries for ``helia_edge.layers.LayerNormalization``.\n\nThe two classes share configuration and weights. Keras's Torch backend cannot normalize\nnon-trailing axes; the helia_edge class can, so this lets models saved with the Keras class\nload on Torch. Entries that normalize the last axis alone keep the Keras class.",
          "examples": [],
          "id": "helia_edge.models.utils.use_helia_layer_normalization",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "use_helia_layer_normalization",
          "params": [
            {
              "description": "The parsed ``config.json`` of a ``.keras`` file.",
              "name": "config",
              "type": "Any"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "The new config and the number of entries swapped.",
              "name": "tuple",
              "type": "tuple[Any, int]"
            }
          ],
          "signature": "use_helia_layer_normalization(config: Any) -> tuple[Any, int]",
          "source": {
            "line": 140,
            "path": "helia_edge/models/utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/utils.py#L140"
          },
          "summary": "Swap Keras LayerNormalization entries for heliaedge.layers.LayerNormalization."
        },
        {
          "description": "Loads a Keras model stored either remotely or locally.\nNOTE: Currently supports wandb, s3, and https for remote.\n\nOn the Torch backend, ``.keras`` files are adapted before loading: names containing ``.``\n(common in models saved by earlier helia-edge versions) are renamed to use ``_``, and Keras\n``LayerNormalization`` layers over non-trailing axes load as\n``helia_edge.layers.LayerNormalization``; see ``undot_layer_names`` and\n``use_helia_layer_normalization``. Other formats load unchanged.",
          "examples": [],
          "id": "helia_edge.models.utils.load_model",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "load_model",
          "params": [
            {
              "description": "Source path\nWANDB: wandb:[[entity/]project/]collectionName:[alias]\nFILE: file:/path/to/model.tf\nS3: s3:bucket/prefix/model.tf\nhttps: https://path/to/model.tf",
              "name": "model_path",
              "type": "str"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Model: Model",
              "type": "keras.Model"
            }
          ],
          "signature": "load_model(model_path: os.PathLike) -> keras.Model",
          "source": {
            "line": 195,
            "path": "helia_edge/models/utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/utils.py#L195"
          },
          "summary": "Loads a Keras model stored either remotely or locally."
        },
        {
          "description": "Appends layers to a model by cloning it and adding the layers.",
          "examples": [],
          "id": "helia_edge.models.utils.append_layers",
          "kind": "function",
          "language": "python",
          "members": [],
          "name": "append_layers",
          "params": [
            {
              "description": "Model",
              "name": "model",
              "type": "keras.Model"
            },
            {
              "description": "Layers to append",
              "name": "layers",
              "type": "list[keras.layers.Layer]"
            },
            {
              "default": "True",
              "description": "Copy weights. Defaults to True.",
              "name": "copy_weights",
              "type": "bool"
            }
          ],
          "raises": [],
          "returns": [
            {
              "description": "keras.Model: Model",
              "type": "keras.Model"
            }
          ],
          "signature": "append_layers(model: keras.Model, layers: list[keras.Layer], copy_weights: bool = True) -> keras.Model",
          "source": {
            "line": 284,
            "path": "helia_edge/models/utils.py",
            "url": "https://github.com/AmbiqAI/helia-edge/blob/f341fb11f7f5d77a4974ba8273c4cd55d67c21f0/helia_edge/models/utils.py#L284"
          },
          "summary": "Appends layers to a model by cloning it and adding the layers."
        }
      ]
    }
  ],
  "name": "helia_edge"
}
