from torch.utils.tensorboard import SummaryWriter
遇到报错:
File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 220, in __init__
self._get_file_writer()
File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 251, in _get_file_writer
self.flush_secs, self.filename_suffix)
File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\torch\utils\tensorboard\writer.py", line 61, in __init__
log_dir, max_queue, flush_secs, filename_suffix)
File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\tensorboard\summary\writer\event_file_writer.py", line 72, in __init__
tf.io.gfile.makedirs(logdir)
File "D:\anaconda3\envs\pytorch_py37\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__
return getattr(load_once(self), attr_name)
AttributeError: module 'tensorflow' has no attribute 'io'
虽然Pytorch直接使用的是tensorboard,但还是需要配合tensorflow使用,解决方法:
pip install tensorflow==2.0
问题解决!