Reading back TensorBoard data

Warning

The functionality described in this page is still experimental, and the interface might change without warning in future releases.

TensorBoardLogger allows you to read data that has been serialized to TensorBoard, either from Julia or from other applications (e.g. Python).

The simplest way to collect all data from TensorBoard is to use the high-level conversion to MVHistory from ValueHistories.jl package.

using TensorBoardLogger, ValueHistories

tb_logger = TBLogger("testlog", tb_overwrite)

with_logger(tb_logger) do
    for i=1:5
        @info "test" val=i b=i*2 mat=i.*ones(3) mat2=10 .*i.*ones(3,2)
    end
end

hist = convert(MVHistory, tb_logger)

If you want to read data that have been saved previously, you can also construct a read-only object TBReader by passing it the path of the folder containing the data to be deserialized.

Alternatively, you can use the method map_summaries to iterate a function of your choice among the data contained in a logger. This function takes two arguments: a function and the path/TBLogger to the data.

The function is mapped across all logged summaries. Its signature should be fun(tag, iteration, value), where tag is a String with the tag used to serialize the data, iteration is an Int corresponding to the iteration at which the data was serialized, and value is the serialized value.

An attempt is made to reconstruct as much as possible the original data, but in the serialization process data is usually converted to lower precision and compressed, so sometimes it's not the case.

hist = MVHistory

TensorBoardLogger.map_summaries(tb_logger) do tag, iter, val
    push!(hist, Symbol(tag), iter, val)
end

All those functions also take as optional keywork arguments a collection of iterations or tags, and will only map over summaries with the desired tags/iterations.

Reference

TensorBoardLogger.tagsFunction
tags(logger)

Returns a set of all the strings used as tags in messages serialized by logger.

logger can be a TBLogger or the path of a valid TensorBoard logdir.

source
TensorBoardLogger.stepsFunction
steps(logger)

Returns a set of all the steps used as tags in messages serialized by logger.

logger can be a TBLogger or the path of a valid TensorBoard logdir.

source
TensorBoardLogger.map_summariesFunction
map_summaries(fun, path; purge=true, tags=all, steps=all, smart=true)

Maps the function fun(name, value) on all the values logged to the folder at path. The function is called sequentially, starting from the first event till the last.

When the keyword argument purge==true, if the i+1-th file begins with a purge at step s, the i-th file is read only up to step s.

fun should take 3 arguments: (1) a String representing the name/tag of the logged value (2) an Integer, representing the step number (3) a value, which can be of the following types:

Optional kwargs tags takes as input a collection of Strings, and will only iterate across tags summaries with a tag in that collection.

Optional kwargs steps takes as input a collection of integers, and will only iterate across events with step within that collection.

Optional kwarg smart=[true] attempts to reconstruct N-dimensional arrays, complex values and 3-dim images, that are decomposed when serialzied to tensorboard. This feature works with .proto files generated by TensorBoardLogger itself, but it is untested with files generated by TensorFlow.

source
TensorBoardLogger.map_eventsFunction
map_summaries(fun, path; purge=true, steps=all)

Maps the function fun(event) on all the event logged to the folder at path. The function is called sequentially, starting from the first event till the last.

When the keyword argument purge==true, if the i+1-th file begins with a purge at step s, the i-th file is read only up to step s.

Also metadata events, without any real data attached are mapped. You can detect those by hasproperty(event, :summary) == false

Optional kwargs steps takes as input a collection of integers, and will only iterate across events with step within that collection.

source