同学你好,这里应该需要让训练集和测试集统一操作,如果训练集上归一化了,那么测试集上也需要归一化。
而关于这里的逻辑,我在搭建graph的时候已经做了归一化,所以感觉你这里对测试集再做归一化重复了。
见代码中的最后一行。
x = tf.placeholder(tf.float32, [batch_size, 3072])
y = tf.placeholder(tf.int64, [batch_size])
is_training = tf.placeholder(tf.bool, [])# [None], eg: [0,5,6,3]x_image = tf.reshape(x, [-1, 3, 32, 32])# 32*32x_image = tf.transpose(x_image, perm=[0, 2, 3, 1])
x_image_arr = tf.split(x_image, num_or_size_splits=batch_size, axis=0)
result_x_image_arr = []
for x_single_image in x_image_arr:
# x_single_image: [1, 32, 32, 3] -> [32, 32, 3]
x_single_image = tf.reshape(x_single_image, [32, 32, 3])
data_aug_1 = tf.image.random_flip_left_right(x_single_image)
data_aug_2 = tf.image.random_brightness(data_aug_1, max_delta=63)
data_aug_3 = tf.image.random_contrast(
data_aug_2, lower=0.2, upper=1.8)
x_single_image = tf.reshape(data_aug_3, [1, 32, 32, 3])
result_x_image_arr.append(x_single_image)
result_x_images = tf.concat(result_x_image_arr, axis=0)
normal_result_x_images = result_x_images / 127.5 - 1