Patches tensor as produced by extract_patches.
For 2D patches: 3D (gH, gW, pH*pW*C) or
4D (N, gH, gW, pH*pW*C).
For 3D patches: 4D (gD, gH, gW, pD*pH*pW*C) or
5D (N, gD, gH, gW, pD*pH*pW*C).
With data_format="channels_first" the flat patch dim comes
first instead: (pH*pW*C, gH, gW) / (N, pH*pW*C, gH, gW)
for 2D patches, (pD*pH*pW*C, gD, gH, gW) /
(N, pD*pH*pW*C, gD, gH, gW) for 3D patches.
size
Patch size, matching the size used for extraction.
Length 2 tuple for 2D, length 3 tuple for 3D, or int.
output_size
Target spatial shape of the reconstruction. Length 2
tuple (H, W) for 2D, length 3 tuple (D, H, W) for 3D. With
padding="valid" this may be omitted (None) and is then
inferred from the patch grid; if given, it must equal
(grid - 1) * stride + size per dim — the region covered by
the extracted patches, i.e. the original size cropped down to
a multiple of size in the non-overlapping case.
With padding="same" it is required: pass the original
spatial shape so the padding added during extraction can be
unambiguously removed.
strides
Currently must equal size (non-overlapping). Defaults
to size.
padding
"same" or "valid", matching the extraction.
data_format
A string specifying the data format of the input tensor.
Either "channels_last" or "channels_first". With
"channels_first" the reconstruction is returned in
(C, H, W) / (N, C, H, W) layout.
If not specified, defaults to keras.config.image_data_format.
Returns
Reconstructed image/volume:
2D: 3D (unbatched) or 4D (batched).
3D: 4D (unbatched) or 5D (batched).
# 3D patches: pass a length-3 `size`volume=np.random.random((2,9,9,9,3)).astype("float32")patches=keras.ops.image.extract_patches(volume,(3,3,3))recon=keras.ops.image.reconstruct_patches(patches,size=(3,3,3),output_size=(9,9,9))recon.shape(2,9,9,9,3)
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]