【发布时间】:2018-09-30 07:30:57
【问题描述】:
我想做图像增强,例如在张量流中旋转随机角度。在每批中,我想为每张图片旋转不同的随机角度。我可以通过使用 tf.contrib.image.rotate 到 image_batch 和随机生成的角度张量来做到这一点:
radian = tf.random_uniform(
(batch_size),
minval=-ROT_TH,
maxval=ROT_TH,
dtype=tf.float32,
seed=None,
name=None
)
rotated_batch = tf.contrib.image.rotate(image_batch, radian)
但是,如果我使用allow_smaller_final_batch=True 构建批处理,batch_size 将毫无用处,因为image_batch 没有固定的批处理大小。并且旋转会失败,因为弧度和image_batch的N维不一样。
我该如何解决?
【问题讨论】:
标签: python tensorflow data-augmentation