TensorFlow - random_crop 在 Cifar10 示例中做什么?

TensorFlow - What is random_crop doing in Cifar10 example?

在 TensorFlow 示例中的 Cifar10 示例中,他们通过裁剪、翻转、增亮、对比和美白的随机组合来扭曲图像。这个概念是有道理的,除了裁剪对我来说有点奇怪。网络的图像需要具有相同的尺寸,裁剪代码如下所示:

  height = IMAGE_SIZE
  width = IMAGE_SIZE

  # Image processing for training the network. Note the many random
  # distortions applied to the image.

  # Randomly crop a [height, width] section of the image.
  distorted_image = tf.random_crop(reshaped_image, [height, width, 3])

由于高度和宽度是基于图像大小的,所以这实际上有什么作用吗?

在示例中,IMAGE_SIZE 设置为 24。所以基本上这段代码所做的是 select 一个随机选择的偏移量并提取一个 24 X 24 补丁。它可能确保偏移量的选择方式可以在没有任何环绕或其他奇怪边界条件的情况下提取补丁,或者它可能会填充它(应该很容易检查)。

我想 IMAGE_SIZE 可以更好地命名为 PATCH_SIZE 之类的。注意原始 CIFAR 10 输入图像是 32 x 32