How to get the number of steps until a certain accuracy in keras?

I want to see how many steps does it take for my model to reach a certain accuracy.Say 90 percent on cifar10.How can I get this info from the keras model ?

EDIT: accuracy in each epoch is accessible in history object fit() returns,but im looking for accuracy in each step

Solution:

I made a callback object that keeps loss in each step

import pickle
from tensorflow.keras.callbacks import Callback

class LossHistory(Callback):
    def __init__(self,path='',name=''):
        super(Callback, self).__init__()
        self.path = path
        self.name=name
        self.accuracy = []
        self.losses=[]
    
    def on_batch_end(self, batch, logs={}):
        self.accuracy.append(logs.get('accuracy'))
        self.losses.append(logs.get('loss'))
    
        history_={}
        history_['accuracy']=self.accuracy
        history_['loss']=self.losses
    
        with open(self.path+self.name+'_history.pkl', 'wb') as f:
            pickle.dump(history_,f)

Topic epochs keras tensorflow accuracy

Category Data Science


When you train the model using the .fit() call, it actually returns an object called history. Train the model using history = model.fit(x_train, y_train...) instead and then once training is complete, you can access the history.history dictionary to see this kind of info.

Refer to https://machinelearningmastery.com/display-deep-learning-model-training-history-in-keras/ for more information

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.