持续训练验证准确性问题

时间:2020-06-16 20:56:26

标签: tensorflow keras neural-network conv-neural-network

我有一个约500个.mat文件的数据集,其中300个训练文件和200个测试文件是很小的裁剪图像,每个图像最多3kb。当我尝试使用以下参数在下面的体系结构上进行训练时,我得到了69%的测试准确度和损失,并且在25个时期内的验证准确度仍保持在51%左右。我想知道如何提高测试准确性并解决持续验证准确性问题。 注意:该问题是二进制分类问题,并且类别拆分比例为60:40

weight_decay = 1e-3
model = models.Sequential()
model.add(layers.Conv2D(16, (3, 3), kernel_regularizer=regularizers.l2(weight_decay),padding='same',input_shape=X_train.shape[1:]))
model.add(layers.Activation('relu'))
model.add(layers.Dropout(0.2))
model.add(layers.Conv2D(32, (3, 3),kernel_regularizer=regularizers.l2(weight_decay), padding='same'))
model.add(layers.Activation('relu'))
#model.add(layers.Dropout(0.2))
model.add(layers.Flatten())
#model.add(layers.Dropout(0.4))
model.add(layers.Dense(20, activation='relu'))
model.add(layers.Dropout(0.50))
model.add(layers.Dense(1, activation='sigmoid'))

model.compile(loss='binary_crossentropy', optimizer=optimizers.adam(lr=0.001), metrics=['acc'])
es_callback = callbacks.EarlyStopping(monitor='val_loss', patience=5)



history= model.fit(#train_generator,
                    X_train,Y_train,
                            batch_size= batch_size,
                            #steps_per_epoch=trainSize,
                            epochs=25,
                            validation_data=(X_val,Y_val),#val_generator,
                            #validation_steps=valSize,
                            #callbacks=[LearningRateScheduler(lr_schedule)]
                            callbacks=[es_callback]
                            )

0 个答案:

没有答案