View source on GitHub
|
Reconstructs an image from a tensor of extracted patches.
tf.experimental.fold(
patches,
output_size,
sizes,
strides,
padding='VALID',
rates=1,
reduction='sum'
)
This op acts as an inverse of tf.image.extract_patches.It takes a
tensor of patches and folds them back into an image. When patches overlap
(i.e., when strides are smaller than the patch sizes), the reduction
argument determines whether the overlapping pixel values are
accumulated(summed) or averaged.
tf.config.experimental.enable_op_determinism()
When op determinism is enabled, TensorFlow ops will be deterministic.
This means that if an op is run multiple times with
the same inputs on the same hardware,
it will have the exact same outputs each time.
See tf.config.experimental.enable_op_determinism for details.
Args | |
|---|---|
patches
|
A 4D Tensor of shape (batch, out_h, out_w, patch_dim), where
patch_dim = kernel_h * kernel_w * channels. This matches the standard
output format of tf.image.extract_patches.
|
output_size
|
A tuple of integers (height, width) specifying the spatial
dimensions of the reconstructed image (before removing padding if
padding="VALID").
|
sizes
|
An int or tuple (kernel_h, kernel_w) specifying the size of each
patch.
|
strides
|
An int or tuple (stride_h, stride_w) specifying the step size
between patches. A single value int specifies the same stride for both
height and width.
|
padding
|
A str ("VALID", "SAME") or an int. - "VALID": No padding is
applied (default). - "SAME": Matches the padding behavior of
tf.image.extract_patches. - int: Applies symmetric padding of this
exact value to all sides.
|
rates
|
An int or tuple (dilation_h, dilation_w) specifying the dilation
rate (spacing between kernel elements). Must be >= 1. Defaults to 1.
|
reduction
|
A str, either "sum" or "mean". Specifies how to aggregate
pixel values from overlapping patches. Defaults to "sum".
|
Returns | |
|---|---|
A 4D Tensor of shape (batch, height, width, channels).
|
View source on GitHub