How to define the callback in Deep Learning?

Would you please guide me what the philosophy of Callbacks is? In other words, how can I define them for each unique problem?

Upvotes: 0

Views: 443

Answers (1)

Romeo Kienzler
Romeo Kienzler

Reputation: 3537

I assume you are taking about keras. So callbacks are used to execute code during training. Everything is explained quite well here

Here an example on how to log loss during training:

class LossHistory(Callback):
    def on_train_begin(self, logs={}):
        self.losses = []

    def on_batch_end(self, batch, logs={}):
        self.losses.append(logs.get('loss'))
        print logs.get('loss')

model.fit(data, data, epochs=50, batch_size=72, validation_data=(data, data), verbose=0, shuffle=False,callbacks=[LossHistory()])

Upvotes: 2

Related Questions