tensorflow/models · error · ValueError

Expected features is a rank-5 tensor. Got shape %s

Error message

Expected features is a rank-5 tensor. Got shape %s

What it means

Error "Expected features is a rank-5 tensor. Got shape %s" thrown in tensorflow/models.

Source

Thrown at official/projects/videoglue/modeling/heads/action_transformer.py:213

           inputs: Mapping[str, tf.Tensor],
           training: bool = False) -> Mapping[str, tf.Tensor]:
    """Forward calls.

    Args:
      inputs: the inputs dictionary contains
        'features': the instance embeddings in shape [B, T', H, W, C].
        'instances_positions': the instance boxes in shape [B, T, N, 4].
        'instances_mask': the validity mask for each instance position, in
          [B, T, N].
      training: whether in training mode.

    Returns:
      the final action classification.
    """
    features = inputs['features']
    instances_position = inputs['instances_position']
    if features.shape.ndims != 5:
      raise ValueError('Expected features is a rank-5 tensor. Got shape %s' %
                       features.shape)

    if self._use_positional_embedding:
      features = self._add_positional_embedding(features)

    # Perform RoI-pooling.
    h, w = _get_shape(features)[2:4]
    roi_features = {'0': tf.reduce_mean(features, axis=1)}
    unnormalized_boxes = instances_position * tf.convert_to_tensor(
        [h, w, h, w], instances_position.dtype)
    # roi_features in shape [B, N, h, w, C]
    roi_features = self._roi_aligner(
        roi_features, unnormalized_boxes, training=training)
    # Perform average_pooling on ROI-pooled features.
    b, n, ch, cw, cc = _get_shape(roi_features)
    roi_features = tf.reshape(roi_features, [b * n, ch, cw, cc])
    roi_features = self._max_pooler(roi_features)
    roi_features = tf.reshape(roi_features, [b, n, cc])

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/videoglue/modeling/heads/action_transformer.py:213 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/ca40c2a7178333b8. Report an issue: GitHub.