<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/heads/dense_prediction_heads.py#L25-L534) |

Creates a RetinaNet head.

    tfm.vision.heads.RetinaNetHead(
        min_level: int,
        max_level: int,
        num_classes: int,
        num_anchors_per_location: (int | dict[str, int]),
        num_convs: int = 4,
        num_filters: int = 256,
        attribute_heads: Optional[List[Dict[str, Any]]] = None,
        share_classification_heads: bool = False,
        use_separable_conv: bool = False,
        activation: str = 'relu',
        use_sync_bn: bool = False,
        norm_momentum: float = 0.99,
        norm_epsilon: float = 0.001,
        kernel_regularizer: Optional[tf_keras.regularizers.Regularizer] = None,
        bias_regularizer: Optional[tf_keras.regularizers.Regularizer] = None,
        num_params_per_anchor: int = 4,
        share_level_convs: bool = True,
        **kwargs
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `min_level` | An `int` number of minimum feature level. |
| `max_level` | An `int` number of maximum feature level. |
| `num_classes` | An `int` number of classes to predict. |
| `num_anchors_per_location` | Number of anchors per pixel location. If an `int`, the same number is used for all levels. If a `dict`, it specifies the number at each level. |
| `num_convs` | An `int` number that represents the number of the intermediate conv layers before the prediction. |
| `num_filters` | An `int` number that represents the number of filters of the intermediate conv layers. |
| `attribute_heads` | If not None, a list that contains a dict for each additional attribute head. Each dict consists of 4 key-value pairs: `name`, `type` ('regression' or 'classification'), `size` (number of predicted values for each instance), and `prediction_tower_name` (optional, specifies shared prediction towers.) |
| `share_classification_heads` | A `bool` that indicates whether sharing weights among the main and attribute classification heads. |
| `use_separable_conv` | A `bool` that indicates whether the separable convolution layers is used. |
| `activation` | A `str` that indicates which activation is used, e.g. 'relu', 'swish', etc. |
| `use_sync_bn` | A `bool` that indicates whether to use synchronized batch normalization across different replicas. |
| `norm_momentum` | A `float` of normalization momentum for the moving average. |
| `norm_epsilon` | A `float` added to variance to avoid dividing by zero. |
| `kernel_regularizer` | A `tf_keras.regularizers.Regularizer` object for Conv2D. Default is None. |
| `bias_regularizer` | A `tf_keras.regularizers.Regularizer` object for Conv2D. |
| `num_params_per_anchor` | Number of parameters required to specify an anchor box. For example, `num_params_per_anchor` would be 4 for axis-aligned anchor boxes specified by their y-centers, x-centers, heights, and widths. |
| `share_level_convs` | An optional bool to enable sharing convs across levels for classnet, boxnet, classifier and box regressor. If True, convs will be shared across all levels. |
| `**kwargs` | Additional keyword arguments to be passed. |

<br />

## Methods

### `call`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/modeling/heads/dense_prediction_heads.py#L451-L527)

    call(
        features: Mapping[str, tf.Tensor]
    )

Forward pass of the RetinaNet head.

<br />

<br />

<br />

| Args ||
|---|---|
| `features` | A `dict` of [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) where <br /> - key: A `str` of the level of the multilevel features. - values: A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor), the feature map tensors, whose shape is \[batch, height_l, width_l, channels\]. |

<br />

<br />

<br />

| Returns ||
|---|---|
| `scores` | A `dict` of [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) which includes scores of the predictions. <br /> - key: A `str` of the level of the multilevel predictions. - values: A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of the box scores predicted from a particular feature level, whose shape is \[batch, height_l, width_l, num_classes \* num_anchors_per_location\]. |
| `boxes` | A `dict` of [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) which includes coordinates of the predictions. - key: A `str` of the level of the multilevel predictions. - values: A [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) of the box scores predicted from a particular feature level, whose shape is \[batch, height_l, width_l, num_params_per_anchor \* num_anchors_per_location\]. |
| `attributes` | a dict of (attribute_name, attribute_prediction). Each `attribute_prediction` is a dict of: - key: `str`, the level of the multilevel predictions. - values: `Tensor`, the box scores predicted from a particular feature level, whose shape is \[batch, height_l, width_l, attribute_size \* num_anchors_per_location\]. Can be an empty dictionary if no attribute learning is required. |