I've tried to make transfer learning via keras.applications like here (https://keras.io/applications/) for binary classification of images (crocodiles and clocks).
load model without top layers
add my dense layer at the top of resnet50
prepare data (resize (32,32,3) -> (224, 224,3)) and split into train & test
EVALUATE ON TRAIN
Descpite loss' decrease and accuracy' increase during fit() method, the model always predicted the one class for every instance. There was class balance 50\50 (in test and train) hence on train\test accuracy was 0.5
EVALUATE ON TEST
There was the same result.
I've tried a lot of different things:
- Change learning_rate
- Change optimizer (RMSProp\SGD)
- Use fit_generator() inster fit()
- Use another losses such as 'categorical_crossentropy' with one-hotted target
- Use another activation: 'softmax'.
Eventually i've decided to use tensorflow and write CNN from scratch using Keras layers:
I've found out that if i use K.learning_phase() = 1 (train phase):
i'll recieve expected result:
accuracy on train ~ 0.99 accuracy on test ~ 0.82
If K.learning_phase() = 0 (test phase):
It's still something strange:
accuracy on train ~ 0.5 accuracy on test ~ 0.5
I have no idea why it happens and how to manage it. I hope somebody would help me. Thanks in advance.