View source on GitHub
|
Randomly crops a tensor to a given size in a deterministic manner.
tf.image.stateless_random_crop(
value, size, seed, name=None
)
Used in the notebooks
| Used in the tutorials |
|---|
Slices a shape size portion out of value at a uniformly chosen offset.
Requires value.shape >= size.
If a dimension should not be cropped, pass the full size of that dimension.
For example, RGB images can be cropped with
size = [crop_height, crop_width, 3].
Guarantees the same results given the same seed independent of how many
times the function is called, and independent of global seed settings (e.g.
tf.random.set_seed).
Usage Example:
image = [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]seed = (1, 2)tf.image.stateless_random_crop(value=image, size=(1, 2, 3), seed=seed)<tf.Tensor: shape=(1, 2, 3), dtype=int32, numpy=array([[[1, 2, 3],[4, 5, 6]]], dtype=int32)>
Returns | |
|---|---|
A cropped tensor of the same rank as value and shape size.
|
View source on GitHub