keras-team/keras · error · TypeError
Invalid `size` argument. Expected an int or a tuple. Receive
Error message
Invalid `size` argument. Expected an int or a tuple. Received: size={size} of type {type(size).__name__} What it means
Error "Invalid `size` argument. Expected an int or a tuple. Received: size={size} of type {type(size).__name__}" thrown in keras-team/keras.
Source
Thrown at keras/src/ops/image.py:729
>>> # 3D patches from batch of volumes
>>> volumes = np.random.random(
... (2, 10, 10, 10, 3)
... ).astype("float32")
>>> patches = keras.ops.image.extract_patches(volumes, (3, 3, 3))
>>> patches.shape
(2, 3, 3, 3, 81)
>>> # 3D patches from single volume
>>> volume = np.random.random((10, 10, 10, 3)).astype("float32")
>>> patches = keras.ops.image.extract_patches(volume, (3, 3, 3))
>>> patches.shape
(3, 3, 3, 81)
"""
# Validate size argument
if not isinstance(size, int):
if not isinstance(size, (tuple, list)):
raise TypeError(
"Invalid `size` argument. Expected an int or a tuple. "
f"Received: size={size} of type {type(size).__name__}"
)
if len(size) not in (2, 3):
raise ValueError(
"Invalid `size` argument. Expected a tuple of length 2 or 3. "
f"Received: size={size} with length {len(size)}"
)
# 2D patch extraction (default)
if any_symbolic_tensors((images,)):
return ExtractPatches(
size=size,
strides=strides,
dilation_rate=dilation_rate,
padding=padding,
data_format=data_format,
).symbolic_call(images)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/ops/image.py:729 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/1a34888bc363dd7f.
Report an issue: GitHub.