{"record":{"id":"4bbad4f7b8d4e0f6","repo":"tensorflow/models","slug":"shape-of-array-should-be-but-found","errorCode":null,"errorMessage":"Shape of array should be {}, but {} found","messagePattern":"Shape of array should be (.+?), but (.+?) found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/pointpillars/utils/utils.py","lineNumber":29,"sourceCode":"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Contains utility functions for pointpillars.\"\"\"\n\nimport collections\nfrom typing import Any, List, Mapping, Tuple\n\nimport numpy as np\nimport tensorflow as tf, tf_keras\n\n\nCLASSES = {'vehicle': 1, 'pedestrian': 2, 'cyclist': 3}\n\n\ndef assert_shape(x: np.ndarray, shape: List[int]):\n  if tuple(x.shape) != tuple(shape):\n    raise ValueError('Shape of array should be {}, but {} found'.format(\n        shape, x.shape))\n\n\ndef assert_channels_last():\n  if tf_keras.backend.image_data_format() != 'channels_last':\n    raise ValueError('Only \"channels_last\" mode is supported')\n\n\ndef pad_or_trim_to_shape(x: np.ndarray, shape: List[int]) -> np.ndarray:\n  \"\"\"Pad and trim x to the specified shape, x should have same rank as shape.\n\n  Args:\n    x: An np array.\n    shape: A list of int indicating a array shape.\n\n  Returns:\n    y: An np array with padded/trimmed shape.\n  \"\"\"","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/pointpillars/utils/utils.py#L11-L47","documentation":"Generic shape-validation helper assert_shape: it compares a numpy array's shape tuple against an expected shape list and raises this ValueError on any mismatch; callers use it to enforce the fixed-size pillar/point-cloud layouts PointPillars requires.","triggerScenarios":"Thrown at official/projects/pointpillars/utils/utils.py:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the actual array shape printed in the message against the expected one","Fix the preprocessing/padding step that produced the wrongly shaped array","Use utils.pad_or_trim_to_shape to coerce the array before the assertion"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}