{"record":{"id":"b9c93b8fe49a6c85","repo":"keras-team/keras","slug":"argument-size-must-be-a-tuple-of-two-elements-h-b9c93b","errorCode":null,"errorMessage":"Argument `size` must be a tuple of two elements (height, width). Received: size={size}","messagePattern":"Argument `size` must be a tuple of two elements \\(height, width\\)\\. Received: size=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/image.py","lineNumber":194,"sourceCode":"):\n    data_format = standardize_data_format(data_format)\n    if interpolation not in RESIZE_INTERPOLATIONS:\n        raise ValueError(\n            \"Invalid value for argument `interpolation`. Expected of one \"\n            f\"{RESIZE_INTERPOLATIONS}. Received: interpolation={interpolation}\"\n        )\n    if fill_mode != \"constant\":\n        raise ValueError(\n            \"Invalid value for argument `fill_mode`. Only `'constant'` \"\n            f\"is supported. Received: fill_mode={fill_mode}\"\n        )\n    if pad_to_aspect_ratio and crop_to_aspect_ratio:\n        raise ValueError(\n            \"Only one of `pad_to_aspect_ratio` & `crop_to_aspect_ratio` \"\n            \"can be `True`.\"\n        )\n    if not len(size) == 2:\n        raise ValueError(\n            \"Argument `size` must be a tuple of two elements \"\n            f\"(height, width). Received: size={size}\"\n        )\n    size = tuple(size)\n    target_height, target_width = size\n    if len(images.shape) == 4:\n        if data_format == \"channels_last\":\n            size = (images.shape[0],) + size + (images.shape[-1],)\n        else:\n            size = (images.shape[0], images.shape[1]) + size\n    elif len(images.shape) == 3:\n        if data_format == \"channels_last\":\n            size = size + (images.shape[-1],)\n        else:\n            size = (images.shape[0],) + size\n    else:\n        raise ValueError(\n            \"Invalid images rank: expected rank 3 (single image) \"","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/image.py#L176-L212","documentation":"Shape-specification guard in `resize` (NumPy backend): the target `size` must be exactly two elements — (height, width) — because the op resizes the two spatial dimensions of each image. Passing a scalar, a longer tuple (e.g. including channels or batch), or nested lists fails the length check and this error echoes the received value.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/image.py:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass size=(H, W) with exactly two integers","Strip batch/channel entries from a full output shape: size = full_shape[1:3] for channels_last","Replace a scalar target with an explicit pair, e.g. (size, size)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}