MCPcopy Create free account
hub / github.com/apple/ml-pointersect / flush

Method flush

cdslib/core/utils/print_and_save.py:440–462  ·  view source on GitHub ↗

Flush the buffer to console and tensorboard. Note: It uses the latest epoch, global_step, and batch_idx, so it should be called every iteration.

(self)

Source from the content-addressed store, hash-verified

438 self.logger.info(text)
439
440 def flush(self):
441 """Flush the buffer to console and tensorboard.
442
443 Note:
444 It uses the latest epoch, global_step, and batch_idx, so it should be called every iteration.
445 """
446 # print to console and log file
447 if self.buffer is not None:
448 text = f"[gstep {self.global_step}, epoch {self.epoch}, batch {self.batch_idx}] "
449 for key in sorted(self.buffer.keys()):
450 text += f"{key}={self.buffer[key]:.3e} "
451 self.info(text)
452
453 # send to tensorboard
454 if self.buffer is not None and self.tb_logger is not None:
455 for tag, scalar_value in self.buffer.items():
456 self.tb_logger.add_scalar(tag=tag, scalar_value=scalar_value, global_step=self.global_step)
457
458 if self.tb_logger is not None:
459 self.tb_logger.flush()
460
461 # clear the buffer
462 self.buffer = None
463
464 def close(self):
465 """Close the logger and terminates the tensorboard."""

Callers 3

runMethod · 0.80
_loop_dataloaderMethod · 0.80
_save_to_memmapMethod · 0.80

Calls 2

infoMethod · 0.95
add_scalarMethod · 0.80

Tested by

no test coverage detected