zalandoresearch / fashion-mnist

A MNIST-like fashion product database. Benchmark :point_down:
http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/
MIT License
11.93k stars 3.01k forks source link

Simple convolutional neural network with 93.43% accuracy on testset #94

Closed cmasch closed 6 years ago

cmasch commented 6 years ago

Hi Han, I evaluated some architectures and parameters. I end up with an accuracy of 93.43% on the fashion-MNIST testset. The same network reached an accuracy of 99.43% on MNIST.

https://github.com/cmasch/zalando-fashion-mnist

The architecture in code:

cnn = Sequential()

cnn.add(InputLayer(input_shape=(img_height,img_width,1)))

# Normalization
cnn.add(BatchNormalization())

# Conv + Maxpooling
cnn.add(Convolution2D(64, (4, 4), padding='same', input_shape=(img_height, img_width, channels), activation='relu'))
cnn.add(MaxPooling2D(pool_size=(2, 2)))

# Dropout
cnn.add(Dropout(0.1))

# Conv + Maxpooling
cnn.add(Convolution2D(64, (4, 4), activation='relu'))
cnn.add(MaxPooling2D(pool_size=(2, 2)))

# Dropout
cnn.add(Dropout(0.3))

# Converting 3D feature to 1D feature Vektor
cnn.add(Flatten())

# Fully Connected Layer
cnn.add(Dense(256, activation='relu'))

# Dropout
cnn.add(Dropout(0.5))

# Fully Connected Layer
cnn.add(Dense(64, activation='relu'))

# Normalization
cnn.add(BatchNormalization())

cnn.add(Dense(num_classes, activation='softmax'))
cnn.compile(loss='categorical_crossentropy',
            optimizer=optimizers.Adam(),
            metrics=['accuracy'])

I tried to keep it simple. Additionally I used augmentation to increase the training data. Thanks for the great dataset!

Best Christopher

ArthurAttout commented 5 years ago

Which shape is the X_train supposed to have here ?

EDIT : Nevermind, I encountered errors with shapes, but it was because I didn't categorize my labels

from keras.utils import to_categorical
y_train = to_categorical(y_train)