# tfr.keras.model.create_keras_model

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L30-L77) |

Creates a Functional Keras ranking model.

    tfr.keras.model.create_keras_model(
        network, loss, metrics, optimizer, size_feature_name, list_size=None
    )

A mask is inferred from size_feature_name and passed to the network, along
with feature dictionary as inputs.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `network` | (`tfr.keras.network.RankingNetwork`) A ranking network which generates a list of scores. |
| `loss` | (`tfr.keras.losses._RankingLoss`) A ranking loss. |
| `metrics` | (list) List of ranking metrics, `tfr.keras.metrics._RankingMetric` instances. |
| `optimizer` | (`tf.keras.optimizer.Optimizer`) Optimizer to minimize ranking loss. |
| `size_feature_name` | (str) Name of feature for example list sizes. If not None, this feature name corresponds to a [`tf.int32`](https://www.tensorflow.org/api_docs/python/tf#int32) Tensor of size \[batch_size\] corresponding to sizes of example lists. If `None`, all examples are treated as valid. |
| `list_size` | (int) The list size for example features. If None, use dynamic list size. A fixed list size is required for TPU training. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A compiled ranking Keras model, a [`tf.keras.Model`](https://www.tensorflow.org/api_docs/python/tf/keras/Model) instance. ||

<br />