tensorflow/models · error · ValueError
Only "channels_last" mode is supported
Error message
Only "channels_last" mode is supported
What it means
Error "Only "channels_last" mode is supported" thrown in tensorflow/models.
Source
Thrown at official/projects/pointpillars/utils/utils.py:35
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.
"""
shape = np.array(shape) # pyrefly: ignore[bad-assignment]
# Try to pad from end
pad_end = shape - np.minimum(x.shape, shape)
pad_begin = np.zeros_like(pad_end)
padder = np.stack([pad_begin, pad_end], axis=1)View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/pointpillars/utils/utils.py:35 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/d8786e4b9272bc40.
Report an issue: GitHub.