'Called when an epoch is about to end
Arguments:
callback_data (HDF5 dataset): shared data between callbacks
model (Model): model object
epoch (int): index of epoch that is ending'

def on_epoch_end(self, callback_data, model, epoch):

    start_loss = default_timer()
    nprocessed = 0
    self.loss[:] = 0
    self.eval_set.reset()
    for (x, t) in self.eval_set:
        x = model.fprop(x, inference=True)
        bsz = min((self.eval_set.ndata - nprocessed), self.be.bsz)
        model.cost.get_cost(x, t)
        nsteps = ((x.shape[1] // self.be.bsz) if (not isinstance(x, list)) else (x[0].shape[1] // self.be.bsz))
        costbuf = model.cost.outputs[:, :(bsz * nsteps)]
        nprocessed += bsz
        self.loss[:] = (self.loss + (self.be.sum(costbuf, axis=1) / nsteps))
        mean_cost = float((self.loss.get() / nprocessed))
    callback_data['time/loss'][(epoch // self.epoch_freq)] = (default_timer() - start_loss)
    callback_data['cost/loss'][(epoch // self.epoch_freq)] = mean_cost
