所以我使用Keras(后端Tensorflow)并试图找到一个网来解决cifar10分类。 我做了一个简单的网。我得到几乎100%的准确度,在我看来这意味着它过度拟合。 我的网络有337,834个可训练参数,我有35000个训练图像,大小(32,32,3)(RGB)。 我的问题是“记住”一个图像需要多少参数。 一个参数是否足以记住一个图像,或者它是否需要32 * 32 * 3,因此图片的每个值都有一个参数?
我的另一个问题是:我的验证是否正确完成,使用验证拆分?
谢谢
import keras
from keras.layers import *
#Preprocessing__________________________________________________________________________________________________________
traindata = keras.preprocessing.image.ImageDataGenerator(
rescale=1. / 255, validation_split=0.7)
input = traindata.flow_from_directory('Cifar10/cifar/train',
target_size=(32, 32), color_mode='rgb', batch_size=50,
subset='validation')
#_______________________________________________________________________________________________________________________
#Building Model_________________________________________________________________________________________________________
model = keras.Sequential()
model.add(Deconv2D(filters=32, kernel_size=3, strides=1, input_shape=(32, 32, 3),activation='relu',padding='same'))
model.add(Deconv2D(filters=32, kernel_size=3, strides=1, activation='relu', padding='same'))
model.add(Flatten())
model.add(Dense(units=10, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
print(model.summary())
#_______________________________________________________________________________________________________________________
#Training_______________________________________________________________________________________________________________
model.fit_generator(input, epochs=100, validation_data=input,
callbacks=[keras.callbacks.TensorBoard(write_images=True, log_dir='./'),
keras.callbacks.ModelCheckpoint('temp/Cifar10 .h5', save_best_only=True)],
validation_steps=100)
Layer (type) Output Shape Param #
=================================================================
conv2d_transpose_1 (Conv2DTr (None, 32, 32, 32) 896
_________________________________________________________________
conv2d_transpose_2 (Conv2DTr (None, 32, 32, 32) 9248
_________________________________________________________________
flatten_1 (Flatten) (None, 32768) 0
_________________________________________________________________
dense_1 (Dense) (None, 10) 327690
=================================================================
Total params: 337,834
Trainable params: 337,834
Non-trainable params: 0