pocketpose.utils.stats - PocketPose 0.0.1 documentation

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Edit this page
Toggle table of contents sidebar

# `pocketpose.utils.stats`

The module for computing model statistics.

## Submodules

- `pocketpose.utils.stats.tflite`

## Package Contents

### Functions

`estimate_flops_tflite`(→ float) | Estimates the number of floating point operations in a TFLite model.
`estimate_parameters_tflite`(→ int) | Estimates the number of parameters in a TFLite model.
`get_stats_tflite`(→ tuple[str, dict[str, Any]]) |
`tabulate_stats`(statistics) | Converts raw statistics into list of dictionaries.

pocketpose.utils.stats.estimate_flops_tflite(model_path: str) → float

  Estimates the number of floating point operations in a TFLite model.

  Note: This is a rough estimate which only considers CONV_2D, DEPTHWISE_CONV_2D, FULLY_CONNECTED, ADD, and MUL operators.

  For FULLY_CONNECTED layer, we assume that the number of FLOPs is approximately 2 times the number of elements in the weight matrix, which assumes that each weight participates in one multiplication and one addition.

  For ADD and MUL layers, we assume that each operation is performed element-wise, and so the number of FLOPs is equal to the total number of elements in the input tensor.

  Args:

    model_path (str): Path to TFLite model

  Returns:

    float: Number of estimated GFLOPs in the model

pocketpose.utils.stats.estimate_parameters_tflite(model_path: str) → int

  Estimates the number of parameters in a TFLite model.

  Args:

    model_path (str): Path to TFLite model

  Returns:

    int: Number of parameters in the model

pocketpose.utils.stats.get_stats_tflite(model_path: str) → tuple[str, dict[str, Any]]

pocketpose.utils.stats.tabulate_stats(statistics)

  Converts raw statistics into list of dictionaries.

  Args:

    statistics (dict): The raw statistics.

  Returns:
    list of dict: The statistics in a tabular format. These can be

      directly written to a table using the tabulate package or the write_to_table function in io module.