<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/core/train_utils.py#L491-L519) |

Count the number of parameters if model is possible.

    tfm.core.train_utils.try_count_params(
        model: Union[tf.Module, tf_keras.Model], trainable_only: bool = False
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `model` | Try to count the number of params in this model. |
| `trainable_only` | Whether to calculate trainable params only. This flag is not used when the model has `count_params` attribute. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The number of parameters or None. ||

<br />