Details:
GPU: GTX 1080
Training: ~1.1 Million images belonging to 10 classes
Validation: ~150 Thousand images belonging to 10 classes
Time per Epoch: ~10 hours
I've setup CUDA, cuDNN and Tensorflow( Tensorflow GPU as well).
I don't think my model is that complicated that is takes 10 hours per epoch. I even checked if my GPU was the problem but it wasn't.
Is the training time due to the Fully connected layers?
My model:
model = Sequential()
model.add()
model.add(Conv2D(64, (3, 3), padding="same", strides=2))
model.add(Activation('relu'))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding="same", strides=2))
model.add(Activation('relu'))
model.add(Dropout(0.25))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(3, 3), strides=2))
model.add(Flatten())
model.add(Dense(256))
model.add(Activation('relu'))
model.add(Dense(4096))
model.add(Activation('relu'))
model.add(Dense(10))
model.add(Activation('softmax'))
model.summary()
opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy']
)
Because there is a lot of data I used the ImageDataGenerator.
gen = ImageDataGenerator(
horizontal_flip=True
)
train_gen = gen.flow_from_directory(
'train/',
target_size=(512, 512),
batch_size=5,
class_mode="categorical"
)
valid_gen = gen.flow_from_directory(
'validation/',
target_size=(512, 512),
batch_size=5,
class_mode="categorical"
)