def on_epoch_end(self, *args, **kwargs): if self.epoch_every and ((self.epoch_id % self.epoch_every) == 0): self.model.eval() val_loss, val_acc = score_model_multi_output( self.model, self.loss_function, self.validation_datagen) self.model.train() logger.info('epoch {0} validation loss: {1:.5f}'.format( self.epoch_id, val_loss)) logger.info('epoch {0} validation accuracy: {1:.5f}'.format( self.epoch_id, val_acc)) self.epoch_id += 1 self.batch_id = 0
def on_epoch_end(self, *args, **kwargs): epoch_avg_loss = self.epoch_loss_averager.value epoch_avg_acc = self.epoch_acc_averager.value self.epoch_loss_averager.reset() self.epoch_acc_averager.reset() self.model.eval() val_loss, val_acc = score_model_multi_output(self.model, self.loss_function, self.validation_datagen) self.model.train() logs = { 'epoch_id': self.epoch_id, 'batch_id': self.batch_id, 'epoch_loss': epoch_avg_loss, 'epoch_acc': epoch_avg_acc, 'epoch_val_loss': val_loss, 'epoch_val_acc': val_acc } self._send_numeric_channels(logs) for i, (image, y_pred, y_true) in enumerate( predict_on_batch_multi_output(self.model, self.validation_datagen)): image_with_keypoints = overlay_keypoints(image, y_pred, y_true, self.bins_nr) pill_image = Image.fromarray( (image_with_keypoints * 255.).astype(np.uint8)) self.ctx.channel_send( "plotted key points", neptune.Image(name='epoch{}_batch{}_idx{}'.format( self.epoch_id, self.batch_id, i), description="true and prediction key points", data=pill_image)) if i == self.img_nr: break self.epoch_id += 1
def on_epoch_end(self, *args, **kwargs): epoch_avg_loss = self.epoch_loss_averager.value epoch_avg_acc = self.epoch_acc_averager.value self.epoch_loss_averager.reset() self.epoch_acc_averager.reset() self.model.eval() val_loss, val_acc = score_model_multi_output(self.model, self.loss_function, self.validation_datagen) self.model.train() logs = { 'epoch_id': self.epoch_id, 'batch_id': self.batch_id, 'epoch_loss': epoch_avg_loss, 'epoch_acc': epoch_avg_acc, 'epoch_val_loss': val_loss, 'epoch_val_acc': val_acc } self._send_numeric_channels(logs) self.epoch_id += 1