from tensorflow.keras import layers, regularizers, Sequential, optimizers
import tensorflow as tf
import numpy as np
def regularized_padded_conv2d(*args, **kwargs):
''' 带标准化的卷积 '''
return layers.Conv2D(
*args, **kwargs,
padding='same',
kernel_regularizer=regularizers.l2(5e-5),
bias_regularizer=regularizers.l2(5e-5),
kernel_initializer='glorot_normal'
)
def load_cifar100_with_DataAugmentation():
(train_x, train_y), (test_x, test_y) = tf.keras.datasets.cifar100.load_data()
train_x = np.array(tf.reshape(train_x, shape=(50000, 32, 32, 3)), dtype=np.float) / 255.0
train_y = tf.keras.utils.to_categorical(train_y)
test_x = np.array(tf.reshape(test_x, shape=(10000, 32, 32, 3)), dtype=np.float) / 255.0
test_y = tf.keras.utils.to_categorical(test_y)
train_noise = tf.random.normal(shape=train_x.shape, mean=0.0, stddev=0.05)
train_x = tf.add(train_x, train_noise)
flip_1 = tf.image.flip_up_down(train_x)
flip_2 = tf.image.flip_left_right(train_x)
flip_3 = tf.image.random_flip_up_down(train_x)
flip_4 = tf.image.random_flip_left_right
tensorflow2.0 DenseNet121 训练 cifar100
最新推荐文章于 2023-11-28 21:41:36 发布

最低0.47元/天 解锁文章
7243





