以確定的方式將張量隨機裁剪為給定大小。
用法
tf.image.stateless_random_crop(
value, size, seed, name=None
)參數
-
value輸入張量進行裁剪。 -
size大小為value等級的一維張量。 -
seed形狀 [2] 張量,隨機數生成器的種子。必須具有數據類型int32或int64。 (使用 XLA 時,僅允許使用int32。) -
name此操作的名稱(可選)。
返回
-
與
value和形狀size具有相同等級的裁剪張量。
以統一選擇的偏移量從 value 中切出形狀 size 部分。需要 value.shape >= size 。
如果不應裁剪尺寸,請傳遞該尺寸的完整尺寸。例如,可以使用 size = [crop_height, crop_width, 3] 裁剪 RGB 圖像。
在給定相同的 seed 的情況下保證相同的結果,與調用函數的次數無關,也與全局種子設置無關(例如 tf.random.set_seed )。
使用示例:
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)>
相關用法
- Python tf.image.stateless_random_contrast用法及代碼示例
- Python tf.image.stateless_random_flip_up_down用法及代碼示例
- Python tf.image.stateless_random_jpeg_quality用法及代碼示例
- Python tf.image.stateless_random_hue用法及代碼示例
- Python tf.image.stateless_random_saturation用法及代碼示例
- Python tf.image.stateless_random_flip_left_right用法及代碼示例
- Python tf.image.stateless_random_brightness用法及代碼示例
- Python tf.image.stateless_sample_distorted_bounding_box用法及代碼示例
- Python tf.image.ssim用法及代碼示例
- Python tf.image.sobel_edges用法及代碼示例
- Python tf.image.sample_distorted_bounding_box用法及代碼示例
- Python tf.image.random_brightness用法及代碼示例
- Python tf.image.pad_to_bounding_box用法及代碼示例
- Python tf.image.adjust_hue用法及代碼示例
- Python tf.image.random_contrast用法及代碼示例
- Python tf.image.rot90用法及代碼示例
- Python tf.image.random_hue用法及代碼示例
- Python tf.image.flip_left_right用法及代碼示例
- Python tf.image.convert_image_dtype用法及代碼示例
- Python tf.image.random_saturation用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.image.stateless_random_crop。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
