Keras准确度从未超过19%

时间:2017-11-28 16:42:47

标签: machine-learning computer-vision keras

我正在拍摄来自SVHN(街景房号码数据集,斯坦福)的图片,我真的可以帮助找出为什么我的准确度不会超过19%...这本质上是一个MNIST教程更多困难的图像(其他数字可能偏离中心,模糊,阴影等。)

我基本上拍摄每张图像并减去该图像的均值然后我归一化为0-1(除以255)。

管道很简单:

  • 2卷积2d层(32滤镜,3x3)
  • MaxPool(2x2)
  • 辍学(.25)
  • 2卷积2d层(64个滤波器,3x3)
  • Max Pool(2x2)
  • 降(0.25)
  • 平铺
  • 密集的Relu
  • 降(0.5)
  • 密集Softmax(10)
1792/73257 [..............................] - ETA: 3:17 - loss: 2.3241 - acc: 0.1602

1920/73257 [..............................] - ETA: 3:16 - loss: 2.3203 - acc: 0.1625

2048/73257 [..............................] - ETA: 3:14 - loss: 2.3177 - acc: 0.1621

2176/73257 [..............................] - ETA: 3:13 - loss: 2.3104 - acc: 0.1682
...
...
...

53376/73257 [====================>.........] - ETA: 51s - loss: 2.2439 - acc: 0.1879

53504/73257 [====================>.........] - ETA: 51s - loss: 2.2439 - acc: 0.1879

53632/73257 [====================>.........] - ETA: 50s - loss: 2.2439 - acc: 0.1878

53760/73257 [=====================>........] - ETA: 50s - loss: 2.2439 - acc: 0.1879

任何人都可以帮我弄清楚我做错了什么吗?是否有任何提示可以确定为什么它会在正常情况下开始增加然后如此迅速地减少?

我正在使用带有rmsprop优化器的分类交叉熵

时代:20 batch_size:128 image_size:32x32

model = Sequential()
model.add(Convolution2D(32, (3, 3),
                        strides=1,
                        activation='relu',
                        padding='same',
                        input_shape=input_shape,
                        data_format='channels_last'))


model.add(Convolution2D(32, (3, 3), padding='same'))
model.add(MaxPooling2D(pool_size=(2, 2), data_format='channels_last'))


model.add(Dropout(0.25))

model.add(Convolution2D(64, (3, 3), activation='relu'))
model.add(Convolution2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))


model.add(Flatten())
model.add(Dense(model.output_shape[1], activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(10, activation='softmax'))

#METHOD1
# print('compiling model...')
# model.compile(loss='mean_squared_error',
#               optimizer='sgd',
#               metrics=['accuracy'])
# print('fitting model...')
#
# model.fit(X_train, y_train, batch_size=64, epochs=1, verbose=1)


# METHOD2
sgd = SGD(lr=0.05)

model.compile(loss='categorical_crossentropy',
              optimizer=sgd,
              metrics=['accuracy'])

model.fit(X_train, y_train,
          epochs=20,
          batch_size=128)
score = model.evaluate(X_test, y_test, batch_size=128)

0 个答案:

没有答案