簡體   English   中英

如何在 pytorch 中使用張量板?

[英]How do I use tensorboard with pytorch?

我正在關注 pytorch tensorboard 教程: https ://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html。

但由於以下錯誤,我什至無法啟動:

from torch.utils.tensorboard import SummaryWriter
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/apps/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py in <module>
      1 try:
----> 2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:

ModuleNotFoundError: No module named 'tensorboard'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-4-c8ffdef1cfab> in <module>
----> 1 from torch.utils.tensorboard import SummaryWriter
      2 
      3 # default `log_dir` is "runs" - we'll be more specific here
      4 writer = SummaryWriter('runs/fashion_mnist_experiment_1')

~/apps/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py in <module>
      2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:
----> 4     raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. '
      5                       'This should be available in 1.14 or above.')
      6 from .writer import FileWriter, SummaryWriter  # noqa F401

ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.

我通過 conda 安裝了 pytorch 1.14。 我應該安裝其他東西嗎?

該教程可能會讓您知道您需要安裝 tensorboard。 查看pytorch tensorboard 文檔,其中解釋了您需要先安裝 tensorboard。

基本上你可以使用安裝張量板

pip install tensorboard

然后通過運行啟動張量板服務器

tensorboard --logdir=runs

runs目錄是您的摘要編寫器將寫入的位置,也是 tensorboard 服務器讀取以了解要可視化的內容的位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM