def rotate_transform_batch(x, rotation=None):
r = np.random.uniform(-0.5, 0.5, size=x.shape[0]) * rotation
# hack; skimage.transform wants float images to be in [-1, 1]
factor = np.maximum(np.max(x), np.abs(np.min(x)))
x = x / factor
x_out = np.empty_like(x)
for i in range(x.shape[0]):
x_out[i, 0] = tf.rotate(x[i, 0], r[i])
x_out *= factor
return x_out
评论列表
文章目录