tensorflow/models · error · ValueError

Shape of array should be {}, but {} found

Error message

Shape of array should be {}, but {} found

What it means

Error "Shape of array should be {}, but {} found" thrown in tensorflow/models.

Source

Thrown at official/projects/pointpillars/utils/utils.py:29

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Contains utility functions for pointpillars."""

import collections
from typing import Any, List, Mapping, Tuple

import numpy as np
import tensorflow as tf, tf_keras


CLASSES = {'vehicle': 1, 'pedestrian': 2, 'cyclist': 3}


def assert_shape(x: np.ndarray, shape: List[int]):
  if tuple(x.shape) != tuple(shape):
    raise ValueError('Shape of array should be {}, but {} found'.format(
        shape, x.shape))


def assert_channels_last():
  if tf_keras.backend.image_data_format() != 'channels_last':
    raise ValueError('Only "channels_last" mode is supported')


def pad_or_trim_to_shape(x: np.ndarray, shape: List[int]) -> np.ndarray:
  """Pad and trim x to the specified shape, x should have same rank as shape.

  Args:
    x: An np array.
    shape: A list of int indicating a array shape.

  Returns:
    y: An np array with padded/trimmed shape.
  """

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/pointpillars/utils/utils.py:29 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/4bbad4f7b8d4e0f6. Report an issue: GitHub.