tf.image.random_crop
Stay organized with collections
Save and categorize content based on your preferences.
Randomly crops a tensor to a given size.
tf.image.random_crop(
value, size, seed=None, name=None
)
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]
.
Args |
value
|
Input tensor to crop.
|
size
|
1-D tensor with size the rank of value .
|
seed
|
Python integer. Used to create a random seed. See
tf.compat.v1.set_random_seed
for behavior.
|
name
|
A name for this operation (optional).
|
Returns |
A cropped tensor of the same rank as value and shape size .
|
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.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.image.random_crop\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 2 version](/api_docs/python/tf/image/random_crop) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/random_ops.py#L290-L331) |\n\nRandomly crops a tensor to a given size.\n\n#### View aliases\n\n\n**Main aliases**\n\n\\`tf.random_crop\\`\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.image.random_crop`](/api_docs/python/tf/image/random_crop), [`tf.compat.v1.random_crop`](/api_docs/python/tf/image/random_crop), \\`tf.compat.v2.image.random_crop\\`\n\n\u003cbr /\u003e\n\n tf.image.random_crop(\n value, size, seed=None, name=None\n )\n\nSlices a shape `size` portion out of `value` at a uniformly chosen offset.\nRequires `value.shape \u003e= size`.\n\nIf a dimension should not be cropped, pass the full size of that dimension.\nFor example, RGB images can be cropped with\n`size = [crop_height, crop_width, 3]`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `value` | Input tensor to crop. |\n| `size` | 1-D tensor with size the rank of `value`. |\n| `seed` | Python integer. Used to create a random seed. See [`tf.compat.v1.set_random_seed`](../../tf/random/set_random_seed) for behavior. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A cropped tensor of the same rank as `value` and shape `size`. ||\n\n\u003cbr /\u003e"]]