tf.keras.ops.image.extract_patches_3d
Stay organized with collections
Save and categorize content based on your preferences.
Extracts patches from the volume(s).
tf.keras.ops.image.extract_patches_3d(
volumes,
size,
strides=None,
dilation_rate=1,
padding='valid',
data_format=None
)
Args |
volumes
|
Input volume or batch of volumes. Must be 4D or 5D.
|
size
|
Patch size int or tuple (patch_depth, patch_height, patch_width)
|
strides
|
strides along depth, height, and width. If not specified, or
if None, it defaults to the same value as size.
|
dilation_rate
|
This is the input stride, specifying how far two
consecutive patch samples are in the input. Note that using
dilation_rate > 1 is not supported in conjunction with
strides > 1 on the TensorFlow backend.
|
padding
|
The type of padding algorithm to use: "same" or "valid".
|
data_format
|
A string specifying the data format of the input tensor.
It can be either "channels_last" or "channels_first".
"channels_last" corresponds to inputs with shape
(batch, depth, height, width, channels), while "channels_first"
corresponds to inputs with shape
(batch, channels, depth, height, width). If not specified,
the value will default to keras.config.image_data_format().
|
Returns |
|
Extracted patches 4D (if not batched) or 5D (if batched)
|
Examples:
import numpy as np
import keras
# Batched case
volumes = np.random.random(
(2, 10, 10, 10, 3)
).astype("float32") # batch of 2 volumes
patches = keras.ops.image.extract_patches_3d(volumes, (3, 3, 3))
patches.shape
(2, 3, 3, 3, 81)
# Unbatched case
volume = np.random.random((10, 10, 10, 3)).astype("float32") # 1 volume
patches = keras.ops.image.extract_patches_3d(volume, (3, 3, 3))
patches.shape
(3, 3, 3, 81)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2026-10-31 UTC.
[[["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."],[],[]]