@@ -3,6 +3,7 @@ mutable struct TBLogger <: AbstractLogger
33 file:: IOStream
44 all_files:: Dict{String, IOStream}
55 global_step:: Int
6+ step_increment:: Int
67 min_level:: LogLevel
78end
89
@@ -17,21 +18,27 @@ already exists.
1718export tb_append, tb_overwrite, tb_increment
1819
1920"""
20- TBLogger(logdir, [tb_increment ; time=time(), purge_step::Int, min_level=Logging.Info])
21+ TBLogger(logdir[, tb_increment];
22+ time=time(),
23+ purge_step=nothing,
24+ step_increment=1,
25+ min_level=Logging.Info)
2126
2227Creates a TensorBoardLogger in the folder `logdir`. The second (optional)
2328argument specifies the behaviour if the `logdir` already exhists: the default
24- choice `tb_increment` appends an increasing number 1,2... to logdir. Other
25- choices are `tb_overwrite`, which overwrites the previous folder and `tb_append`.
29+ choice `tb_increment` appends an increasing number 1,2... to ` logdir` . Other
30+ choices are `tb_overwrite`, which overwrites the previous folder, and `tb_append`.
2631
27- If `purge_step::Int` is passed, every step before `purge_step` will be ignored
32+ If a `purge_step::Int` is passed, every step before `purge_step` will be ignored
2833by tensorboard (usefull in the case of restarting a crashed computation).
2934
30- `min_level=Logging.Info ` specifies the minimum level of messages logged to
31- tensorboard
35+ `min_level` specifies the minimum level of messages logged to
36+ tensorboard.
3237"""
3338function TBLogger (logdir= " tensorboard_logs/run" , overwrite= tb_increment;
34- time= time (), purge_step:: Union{Int,Nothing} = nothing ,
39+ time= time (),
40+ purge_step:: Union{Int,Nothing} = nothing ,
41+ step_increment = 1 ,
3542 min_level:: LogLevel = Info)
3643
3744 logdir = init_logdir (logdir, overwrite)
@@ -40,7 +47,7 @@ function TBLogger(logdir="tensorboard_logs/run", overwrite=tb_increment;
4047 all_files = Dict (fpath => evfile)
4148 start_step = something (purge_step, 0 )
4249
43- TBLogger (logdir, evfile, all_files, start_step, min_level)
50+ TBLogger (logdir, evfile, all_files, start_step, step_increment, min_level)
4451end
4552
4653"""
@@ -159,6 +166,16 @@ logger when no value is passed by the user.
159166"""
160167set_step! (lg:: TBLogger , step) = lg. global_step = step
161168
169+ """
170+ set_step_increment!(lg, increment) -> Int
171+
172+ Sets the default increment applyed to logger `lg`'s iteration counter
173+ each time logging is performed.
174+
175+ Can be overidden by passing `log_step_increment=some_increment` when logging.
176+ """
177+ set_step_increment! (lg:: TBLogger , step) = lg. global_step = step
178+
162179"""
163180 increment_step!(lg, Δ_Step) -> Int
164181
@@ -208,7 +225,7 @@ function CoreLogging.handle_message(lg::TBLogger, level, message, _module, group
208225 id, file, line; kwargs... )
209226 # Unpack the message
210227 summ = SummaryCollection ()
211- i_step = 1 # :log_step_increment default value
228+ i_step = lg . step_increment # :log_step_increment default value
212229
213230 if ! isempty (kwargs)
214231 data = Vector {Pair{String,Any}} ()
0 commit comments