卷积神经网络测试精度在每个时期后保持不变

时间:2017-07-28 04:36:26

标签: python tensorflow neural-network keras

我看到每次迭代后提高了训练精度,但测试精度在每个时期后仍然固定在0.7545。我理解在某些方面达到了准确性的上限但不明白为什么我至少看不到准确性的微小变化(向上或向下)。我总共训练了大约800张图片。

我尝试过的事情: - 切换到SGD优化器。 - 从学习率0.01开始,减少到0.00000001。 - 删除正则化层。

#PARAMS
dropout_prob = 0.2
activation_function = 'relu'
loss_function = 'categorical_crossentropy'
verbose_level = 1
convolutional_batches = 32
convolutional_epochs = 10
inp_shape = X_train.shape[1:]
num_classes = 3
opt = SGD(lr=0.00001)
opt2 = 'adam'


def train_convolutional_neural():
    y_train_cat = np_utils.to_categorical(y_train, 3) 
    y_test_cat = np_utils.to_categorical(y_test, 3)

    model = Sequential()
    model.add(Conv2D(filters=16, kernel_size=(3, 3), input_shape=inp_shape))
    model.add(Conv2D(filters=32, kernel_size=(3, 3)))
    model.add(MaxPooling2D(pool_size = (2,2)))
    model.add(Dropout(rate=dropout_prob))
    model.add(Flatten())
    #model.add(Dense(64,activation=activation_function))
    model.add(Dropout(rate=dropout_prob))
    model.add(Dense(32,activation=activation_function))
    model.add(Dense(num_classes,activation='softmax'))
    model.summary()
    model.compile(loss=loss_function, optimizer=opt, metrics=['accuracy'])
    history = model.fit(X_train, y_train_cat, batch_size=convolutional_batches, epochs = convolutional_epochs, verbose = verbose_level, validation_data=(X_test, y_test_cat))
    model.save('./models/convolutional_model.h5')

0 个答案:

没有答案