def __init__( self, logdir, max_queue_size=10, flush_secs=120, filename_base=None, filename_suffix=""): with warnings.catch_warnings(): warnings.simplefilter("ignore", Warning) # pylint: disable=no-name-in-module from tensorboard.summary.writer import event_file_writer as writelib util.ensure_dir(logdir) filename_base = filename_base or ("%010d.%s.%s.%s" % ( time.time(), socket.gethostname(), os.getpid(), writelib._global_uid.get())) filename = ( os.path.join(logdir, "events.out.tfevents.%s" % filename_base) + filename_suffix) self._writer = writelib._AsyncWriter( writelib.RecordWriter(open(filename, "wb")), max_queue_size, flush_secs) event = writelib.event_pb2.Event( wall_time=time.time(), file_version="brain.Event:2") self.add_event(event) self.flush()
def AsyncWriter(logdir, max_queue_size=10, flush_secs=120, filename_base=None, filename_suffix=""): with warnings.catch_warnings(): warnings.simplefilter("ignore", Warning) # pylint: disable=no-name-in-module from tensorboard.summary.writer import event_file_writer filename = event_filename(logdir, filename_base=filename_base, filename_suffix=filename_suffix) return event_file_writer._AsyncWriter( event_file_writer.RecordWriter(open(filename, "wb")), max_queue_size, flush_secs)