titu1994 / DenseNet

DenseNet implementation in Keras
MIT License
707 stars 294 forks source link

Failure using Keras' fit_generator attempting to train image classifier #36

Closed michaelmurdock closed 5 years ago

michaelmurdock commented 6 years ago

I created a DenseNet model following the instructions in the README.md. I am using Keras with TF for the back-end to train a model (from scratch) to classify 240x240 images into one of 13 classes.

Attached is a simplified script that shows how I set up the model, generators, and optimizer. The code fails when I call the train_generator's fit_generator method. Attached is the output log.

Here are my package versions:

densenet_simplified.txt densenet_output.txt

Any help in how I might change the configuration to use less memory (if that's what I am doing wrong) would be greatly appreciated.

Thanks,

Michael.

titu1994 commented 6 years ago

Doesn't the Titan X have 12 GB memory? Also, this is the smallest DenseNet that is in the paper so it shoudn't run out of memory. However, this DenseNet model is used for CIFAR 10/100 models.

Perhaps try with subsample_initial_block=True, bottleneck=True

michaelmurdock commented 6 years ago

I was able to get it working by changing the depth. The "default" is depth=40. I changed it to depth=7, and fit_generator is now working. That is, I don't get the memory failure. It's still on the first epoch but the accuracy is going up, so this looks very promising!