def _get_file_writer(self):
"""Returns the default FileWriter instance. Recreates it if closed."""
if not self._write_to_disk:
self.file_writer = DummyFileWriter(logdir=self.logdir)
self.all_writers = {self.file_writer.get_logdir(): self.file_writer}
return self.file_writer
if self.all_writers is None or self.file_writer is None:
if 'purge_step' in self.kwargs.keys():
most_recent_step = self.kwargs.pop('purge_step')
self.file_writer = FileWriter(logdir=self.logdir, **self.kwargs)
self.file_writer.add_event(
Event(step=most_recent_step, file_version='brain.Event:2'))
self.file_writer.add_event(
Event(step=most_recent_step, session_log=SessionLog(status=SessionLog.START)))
else:
self.file_writer = FileWriter(logdir=self.logdir, **self.kwargs)
self.all_writers = {self.file_writer.get_logdir(): self.file_writer}
return self.file_writer
def add_scalar(self, tag, scalar_value, global_step=None, walltime=None):
"""Add scalar data to summary.
File "C:\Users\dell\Anaconda3\envs\tensorenviron\lib\site-packages\tensorboardX\writer.py", line 310, in _get_file_writer self.file_writer = FileWriter(logdir=self.logdir, **self.kwargs) TypeError: __init__() got an unexpected keyword argument 'log_dir'
答案 0 :(得分:0)
问题不在此代码段之内,可能是初始化任何类_get_file_writer
的一部分。您的字典self.kwargs
包含一个log_dir
密钥,您将通过**self.kwargs
将该密钥传递给FileWriter,而tf.summary.FileWriter则期望logdir
。