From 890e3c14d4149a292fad0bf37cbacbd81fffafa8 Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Fri, 22 Sep 2023 15:49:25 +0800 Subject: [PATCH 1/2] fix #7026 Signed-off-by: KumoLiu --- monai/handlers/tensorboard_handlers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/monai/handlers/tensorboard_handlers.py b/monai/handlers/tensorboard_handlers.py index 3eb2fe1280..0b8a351320 100644 --- a/monai/handlers/tensorboard_handlers.py +++ b/monai/handlers/tensorboard_handlers.py @@ -93,8 +93,8 @@ def __init__( self, summary_writer: SummaryWriter | SummaryWriterX | None = None, log_dir: str = "./runs", - iteration_log: bool | Callable[[Engine, int], bool] = True, - epoch_log: bool | Callable[[Engine, int], bool] = True, + iteration_log: bool | Callable[[Engine, int], bool] | int = True, + epoch_log: bool | Callable[[Engine, int], bool] | int = True, epoch_event_writer: Callable[[Engine, Any], Any] | None = None, epoch_interval: int = 1, iteration_event_writer: Callable[[Engine, Any], Any] | None = None, @@ -110,11 +110,13 @@ def __init__( default to create a new TensorBoard writer. log_dir: if using default SummaryWriter, write logs to this directory, default is `./runs`. iteration_log: whether to write data to TensorBoard when iteration completed, default to `True`. - ``iteration_log`` can be also a function and it will be interpreted as an event filter + ``iteration_log`` can be also a function or int. If it is an int, it will be interpreted as the iteration interval + at which the iteration_event_writer is called. If it is a function, it will be interpreted as an event filter (see https://pytorch.org/ignite/generated/ignite.engine.events.Events.html for details). Event filter function accepts as input engine and event value (iteration) and should return True/False. epoch_log: whether to write data to TensorBoard when epoch completed, default to `True`. - ``epoch_log`` can be also a function and it will be interpreted as an event filter. + ``epoch_log`` can be also a function or int. If it is an int, it will be interpreted as the epoch interval + at which the iteration_event_writer is called. If it is a function, it will be interpreted as an event filter See ``iteration_log`` argument for more details. epoch_event_writer: customized callable TensorBoard writer for epoch level. Must accept parameter "engine" and "summary_writer", use default event writer if None. From 6a589658dfbe3d75f6e42fec0125237b10d00c50 Mon Sep 17 00:00:00 2001 From: KumoLiu Date: Fri, 22 Sep 2023 15:52:45 +0800 Subject: [PATCH 2/2] minor fix Signed-off-by: KumoLiu --- monai/handlers/tensorboard_handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/handlers/tensorboard_handlers.py b/monai/handlers/tensorboard_handlers.py index 0b8a351320..9b80f45a41 100644 --- a/monai/handlers/tensorboard_handlers.py +++ b/monai/handlers/tensorboard_handlers.py @@ -116,7 +116,7 @@ def __init__( Event filter function accepts as input engine and event value (iteration) and should return True/False. epoch_log: whether to write data to TensorBoard when epoch completed, default to `True`. ``epoch_log`` can be also a function or int. If it is an int, it will be interpreted as the epoch interval - at which the iteration_event_writer is called. If it is a function, it will be interpreted as an event filter + at which the epoch_event_writer is called. If it is a function, it will be interpreted as an event filter. See ``iteration_log`` argument for more details. epoch_event_writer: customized callable TensorBoard writer for epoch level. Must accept parameter "engine" and "summary_writer", use default event writer if None.