當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python PyTorch SummaryWriter.__init__用法及代碼示例

本文簡要介紹python語言中 torch.utils.tensorboard.writer.SummaryWriter.__init__ 的用法。

用法:

__init__(log_dir=None, comment='', purge_step=None, max_queue=10, flush_secs=120, filename_suffix='')

參數

  • log_dir(string) -保存目錄位置。默認是運行/CURRENT_DATETIME_HOSTNAME,每次運行後都會發生變化。使用分層文件夾結構輕鬆比較運行。例如為每個新實驗傳入“runs/exp1”、“runs/exp2”等,以便在它們之間進行比較。

  • comment(string) -注釋 log_dir 後綴附加到默認 log_dir 。如果指定了log_dir,則此參數無效。

  • purge_step(int) -當記錄在步驟 崩潰並在步驟 重新啟動時,任何 global_step 大於或等於 的事件都將從 TensorBoard 中清除並隱藏。請注意,崩潰和恢複的實驗應該具有相同的 log_dir

  • max_queue(int) -在 ‘add’ 調用之一強製刷新到磁盤之前,掛起事件和摘要的隊列大小。默認為十項。

  • flush_secs(int) -將掛起的事件和摘要刷新到磁盤的頻率(以秒為單位)。默認為每兩分鍾一次。

  • filename_suffix(string) -後綴添加到log_dir 目錄中的所有事件文件名。有關 tensorboard.summary.writer.event_file_writer.EventFileWriter 中文件名構造的更多詳細信息。

創建一個SummaryWriter,它將事件和摘要寫入事件文件。

例子:

from torch.utils.tensorboard import SummaryWriter

# create a summary writer with automatically generated folder name.
writer = SummaryWriter()
# folder location: runs/May04_22-14-54_s-MacBook-Pro.local/

# create a summary writer using the specified folder name.
writer = SummaryWriter("my_experiment")
# folder location: my_experiment

# create a summary writer with comment appended.
writer = SummaryWriter(comment="LR_0.1_BATCH_16")
# folder location: runs/May04_22-14-54_s-MacBook-Pro.localLR_0.1_BATCH_16/

相關用法


注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torch.utils.tensorboard.writer.SummaryWriter.__init__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。