# helia_edge.metrics.flops

## FLOPs Metrics API

FLOPS calculation for keras.Model or keras.Sequential.

**Functions**

| Name | Description |
| --- | --- |
| `get_flops` | Calculate FLOPS for keras.Model or keras.Sequential |

## helia_edge.metrics.flops.get_flops

`function` · `python`

```python
get_flops(model: keras.Model, batch_size: int | None = None, fpath: os.PathLike | None = None) -> float
```

Calculate FLOPS for keras.Model or keras.Sequential.
Ignore operations used in only training mode such as Initialization.

:::note
Only tensorflow backend is supported currently.
Does not support LSTM and GRU.

:::

Example:

```python
model = keras.Sequential([
    keras.layers.Dense(128, activation="relu", input_shape=(784,)),
    keras.layers.Dense(64, activation="relu"),
    keras.layers.Dense(10, activation="softmax"),
])
import helia_edge as helia

model.build()
flops = helia.metrics.get_flops(model, batch_size=1)
print(f"FLOPS: {flops/1e6:.2f}M")
```

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| model | keras.Model \| keras.Sequential | Required | Model |
| batch_size | int | None | Batch size. Defaults to None. |
| fpath | os.PathLike | None | Output file path. Defaults to None. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| float | float | FLOPS |

Source: `helia_edge/metrics/flops.py:17`
