1
$\begingroup$

I am trying to classify some 224x224 RGB images.

I have 3 potential labels, but am currently only supplying training images for 2. My training set has approx. 2K images for both labels.

When I train with simple net I get 0.9+ accuracy within 6 epochs.

When I train with AlexNet I am still only around 0.5 accuracy after 50 epochs.

Why might this be?

def SimpleNet():
    model = keras.Sequential([
        keras.layers.Conv2D(64, kernel_size=3, activation=tf.nn.relu, input_shape=(224, 224, 3)),
        keras.layers.Dropout(0.75),
        keras.layers.Conv2D(32, kernel_size=3, activation=tf.nn.relu),
        keras.layers.Dropout(0.75),
        keras.layers.Flatten(),
        keras.layers.Dense(3, activation=tf.nn.softmax)
    ])
    return model

def AlexNet():
    model = keras.Sequential()

    # 1st Convolutional Layer
    model.add(keras.layers.Conv2D(filters=96, input_shape=(224, 224, 3), kernel_size=(11, 11), strides=(4, 4), padding='valid'))
    model.add(keras.layers.Activation('relu'))
    # Max Pooling
    model.add(keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='valid'))

    # 2nd Convolutional Layer
    model.add(keras.layers.Conv2D(filters=256, kernel_size=(11, 11), strides=(1, 1), padding='valid'))
    model.add(keras.layers.Activation('relu'))
    # Max Pooling
    model.add(keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='valid'))

    # 3rd Convolutional Layer
    model.add(keras.layers.Conv2D(filters=384, kernel_size=(3, 3), strides=(1, 1), padding='valid'))
    model.add(keras.layers.Activation('relu'))

    # 4th Convolutional Layer
    model.add(keras.layers.Conv2D(filters=384, kernel_size=(3, 3), strides=(1, 1), padding='valid'))
    model.add(keras.layers.Activation('relu'))

    # 5th Convolutional Layer
    model.add(keras.layers.Conv2D(filters=256, kernel_size=(3, 3), strides=(1, 1), padding='valid'))
    model.add(keras.layers.Activation('relu'))
    # Max Pooling
    model.add(keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding='valid'))

    # Passing it to a Fully Connected layer
    model.add(keras.layers.Flatten())
    # 1st Fully Connected Layer
    model.add(keras.layers.Dense(4096, input_shape=(224 * 224 * 3,)))
    model.add(keras.layers.Activation('relu'))
    # Add Dropout to prevent overfitting
    model.add(keras.layers.Dropout(0.4))

    # 2nd Fully Connected Layer
    model.add(keras.layers.Dense(4096))
    model.add(keras.layers.Activation('relu'))
    # Add Dropout
    model.add(keras.layers.Dropout(0.4))

    # 3rd Fully Connected Layer
    model.add(keras.layers.Dense(1000))
    model.add(keras.layers.Activation('relu'))
    # Add Dropout
    model.add(keras.layers.Dropout(0.4))

    # Output Layer
    model.add(keras.layers.Dense(3))
    model.add(keras.layers.Activation('softmax'))

    return model
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.