3
$\begingroup$

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)
$\endgroup$
0
$\begingroup$

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

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.