我的问题是当我尝试运行此代码时
if log_to_tensorboard: from torch.utils.tensorboard import SummaryWriter
if log_to_tensorboard: writer = SummaryWriter()
我收到此错误:
((导入SummaryWriter可以正常工作,但是我尝试运行“ writer = SummaryWriter()”,但它不起作用)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-d77d9d09e62b> in <module>
----> 1 writer = SummaryWriter()
/anaconda3/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py in __init__(self, log_dir, comment, purge_step, max_queue, flush_secs, filename_suffix)
223 # and recreated later as needed.
224 self.file_writer = self.all_writers = None
--> 225 self._get_file_writer()
226
227 # Create default bins for histograms, see generate_testdata.py in tensorflow/tensorboard
/anaconda3/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py in _get_file_writer(self)
254 if self.all_writers is None or self.file_writer is None:
255 self.file_writer = FileWriter(self.log_dir, self.max_queue,
--> 256 self.flush_secs, self.filename_suffix)
257 self.all_writers = {self.file_writer.get_logdir(): self.file_writer}
258 if self.purge_step is not None:
/anaconda3/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py in __init__(self, log_dir, max_queue, flush_secs, filename_suffix)
64 log_dir = str(log_dir)
65 self.event_writer = EventFileWriter(
---> 66 log_dir, max_queue, flush_secs, filename_suffix)
67
68 def get_logdir(self):
/anaconda3/lib/python3.6/site-packages/tensorboard/summary/writer/event_file_writer.py in __init__(self, logdir, max_queue_size, flush_secs, filename_suffix)
71 """
72 self._logdir = logdir
---> 73 if not tf.io.gfile.exists(logdir):
74 tf.io.gfile.makedirs(logdir)
75 self._file_name = os.path.join(logdir, "events.out.tfevents.%010d.%s.%s.%s" %
/anaconda3/lib/python3.6/site-packages/tensorboard/lazy.py in __getattr__(self, attr_name)
63 class LazyModule(types.ModuleType):
64 def __getattr__(self, attr_name):
---> 65 return getattr(load_once(self), attr_name)
66
67 def __dir__(self):
AttributeError: module 'tensorflow' has no attribute 'io'
如何解决?我卸载并安装了tensorflow,升级了tensorboard和火炬-并没有帮助我