Keras: Stop learnning when accuracy becomes 1.00

Created on 27 Apr 2017  路  4Comments  路  Source: keras-team/keras

I tried using callbacks but it seems that it take the difference of val_acc of two epoch and if the difference less than defined then it will stop. But, I want to stop the training when val_acc becomes 1.00.

so, how can I stop learning when val_acc becomes 1.00 for n(let's say 5 times ) times continuously.

Most helpful comment

Below is thepart of my code that solve my issue:

for epoch in range (epochs):
    fit = model.fit(X, Y, nb_epoch=1, batch_size=20,validation_split=0.2, verbose=1)
    print epoch
    if fit.history['val_acc'][0]*100 >= 98 :
        break;

may be this solves your problem

All 4 comments

You could try making your own callback. See https://keras.io/callbacks/#callback. Custom callbacks can access the val_acc after each epoch, so you could just make a custom callback class to keep track of how many times in a row the accuracy is 1.0. Look at https://keras.io/callbacks/#create-a-callback for examples of custom callbacks.

Thanks

hi @gauravshelangia how do you using the Callback to custiom it? Do you give your code? Thanks.

Below is thepart of my code that solve my issue:

for epoch in range (epochs):
    fit = model.fit(X, Y, nb_epoch=1, batch_size=20,validation_split=0.2, verbose=1)
    print epoch
    if fit.history['val_acc'][0]*100 >= 98 :
        break;

may be this solves your problem

Was this page helpful?
0 / 5 - 0 ratings