@@ -3,6 +3,7 @@ mutable struct TBLogger <: AbstractLogger
3
3
file:: IOStream
4
4
all_files:: Dict{String, IOStream}
5
5
global_step:: Int
6
+ step_increment:: Int
6
7
min_level:: LogLevel
7
8
end
8
9
@@ -17,21 +18,27 @@ already exists.
17
18
export tb_append, tb_overwrite, tb_increment
18
19
19
20
"""
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)
21
26
22
27
Creates a TensorBoardLogger in the folder `logdir`. The second (optional)
23
28
argument 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`.
26
31
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
28
33
by tensorboard (usefull in the case of restarting a crashed computation).
29
34
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.
32
37
"""
33
38
function 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 ,
35
42
min_level:: LogLevel = Info)
36
43
37
44
logdir = init_logdir (logdir, overwrite)
@@ -40,7 +47,7 @@ function TBLogger(logdir="tensorboard_logs/run", overwrite=tb_increment;
40
47
all_files = Dict (fpath => evfile)
41
48
start_step = something (purge_step, 0 )
42
49
43
- TBLogger (logdir, evfile, all_files, start_step, min_level)
50
+ TBLogger (logdir, evfile, all_files, start_step, step_increment, min_level)
44
51
end
45
52
46
53
"""
@@ -159,6 +166,16 @@ logger when no value is passed by the user.
159
166
"""
160
167
set_step! (lg:: TBLogger , step) = lg. global_step = step
161
168
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
+
162
179
"""
163
180
increment_step!(lg, Δ_Step) -> Int
164
181
@@ -208,7 +225,7 @@ function CoreLogging.handle_message(lg::TBLogger, level, message, _module, group
208
225
id, file, line; kwargs... )
209
226
# Unpack the message
210
227
summ = SummaryCollection ()
211
- i_step = 1 # :log_step_increment default value
228
+ i_step = lg . step_increment # :log_step_increment default value
212
229
213
230
if ! isempty (kwargs)
214
231
data = Vector {Pair{String,Any}} ()
0 commit comments