3

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)

Oxbowerce
  • 8,522
  • 2
  • 10
  • 26
Moeinh77
  • 221
  • 1
  • 5

1 Answers1

0

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

Dan Scally
  • 1,784
  • 8
  • 26