Explicit interface
in addition to the standard logging interface, it is possible to log data to TensorBoard using the functions documented below. All the functions take as first argument a TBLogger
object and as the second argument a String
as the tag under which the data will be logged.
Scalar backend
TensorBoardLogger.log_value
— Functionlog_value(logger, name, value; step=step(logger))
Logs a floating-point variable with name name
at step step
. If value
is a complex number, the real and imaginary part are logged separately.
Distributions backend
TensorBoardLogger.log_histogram
— Functionlog_histogram(logger, name, (bins,weights); step=step(logger))
Logs a histogram under the tag name
on given step
. The histogram must be passed as a tuple holding the N+1
bin edges and the height of the N
bins.
You can also pass the raw data, and a binning algorithm from StatsBase.jl
will be used to bin the data.
log_histogram(logger, name, data::Vector; step=step(logger))
Bins the values found in data
and logs them as an histogram under the tag name
.
TensorBoardLogger.log_vector
— Functionlog_vector(logger, name, data::Vector; step=step(logger))
Logs the vector found in data
as an histogram under the name name
.
Text backend
TensorBoardLogger.log_text
— Functionlog_text(logger::TBLogger, name::String, text::Any; step=step(logger))
Logs text with name name
at step step
- text: If text is a 2-D or 3-D
Array
, it will be rendered as a table or a list. Any other data will be represented as string
Images backend
TensorBoardLogger.log_image
— Functionlog_image(logger::TBLogger, name::AbstractString, imgArray::AbstractArray, format::ImageFormat; step=step(logger))
Log an image using image data and format
- imgArray: image data. A 1-D, 2-D or 3-D
Array
of pixel values. pixel values can be Real [0, 1] or Integer[0, 255] - format: format of the image. It can be one of {L, LN, NL, CL, LC, NCL, NLC, CLN, LCN, HW, WH, HWC, WHC, CHW, CWH, HWN, WHN, NHW, NWH, HWCN, WHCN, CHWN, CWHN, NHWC, NWHC, NCHW, NCWH}
- L: Length
- C: Channel/Color
- H: Height
- W: Width
- N: Observation
logimage(logger, name, obj; [step=currentstep])
Renders the object to PNG and sends it to TensorBoard as an image with tag name
. showable("image/png", obj)
must be true.
TensorBoardLogger.log_images
— Functionlog_images(logger::TBLogger, name::AbstractString, imgArrays::AbstractArray, format::ImageFormat; step=step(logger))
Log multiple images using Array
of images and format
- imgArrays:
Array
of images, e.g. Array{Array{Float64, 3}, 1}.Array
of images can be multidimensional. - format: format which applies to each image in the
Array
of images. It can be one of {L, LN, NL, CL, LC, NCL, NLC, CLN, LCN, HW, WH, HWC, WHC, CHW, CWH, HWN, WHN, NHW, NWH, HWCN, WHCN, CHWN, CWHN, NHWC, NWHC, NCHW, NCWH}
Audio backend
TensorBoardLogger.log_audio
— Functionlog_audio(logger::TBLogger, name::AbstractString, samples::AbstractArray, samplerate::Real; step=step(logger))
Logs an audio clip with name name
at step step
- samples: Array of samples N*C where N = number of samples and C = number of channels
- samplerate: Sampling rate or Sampling frequency: a Real value
TensorBoardLogger.log_audios
— Functionlog_audios(logger::TBLogger, name::AbstractString, samples::AbstractArray, samplerate::Real; step=step(logger))
Logs multiple audio clips at step step
- samples: Array of audio clips which are Arrays of samples N*C where N = number of samples and C = number of channel
- samplerate: Sampling rate or Sampling frequency: a Real value same for all clips
Embeddings backend
TensorBoardLogger.log_embeddings
— Functionlog_embeddings(logger::TBLogger, name::AbstractString, mat::AbstractMatrix; metadata, metadata_header, img_labels, step=step(logger))
Log embedding data to tensorboard and visualize in 3-D or 2-D with PCA, t-SNE or UMAP.
- mat: 2-D
Matrix
of data, with rows representing the samples and columns representing the features - metadata: Array of labels for each sample. Each element across 1st dimenstion will be converted to
string
- metadata_header: 1-D Array. Useful when samples have multiple labels. size should be same as size of each row in
metadata
- img_labels: TBImages object representing image labels for each sample.
- each number of images (N) must be equal to number of samples in
mat
- each image must be a square (H == W)
- the value √N * W must be less than or equal to 8192 because of tensorboard restrictions.
- each number of images (N) must be equal to number of samples in
Custom Scalars plugin
See TensorBoard Custom Scalar page.
For example, to combine in the same plot panel the two curves logged under tags "Curve/1"
and "Curve/2"
you can run once the command:
layout = Dict("Cat" => Dict("Curve" => (tb_multiline, ["Curve/1", "Curve/2"])))
log_custom_scalar(lg, layout)
See also the documentation below
TensorBoardLogger.log_custom_scalar
— Functionlog_custom_scalar(logger, layout::AbstractDict; step = step(logger))
Groups multiple scalars in the same plot to be visualized by the CUSTOMSCALARS plugin. Note that this function sets the metadata: the actual values must be logged separately with `logvalue` and referenced with the correct tag.
The layout
argument is structured as follows:
layout = Dict(category => Dict(name => (chart_type, [tag1, tag2, ...])))
where category
is the main tag for the plot, name
is the plot's name, chart_type
is one between tb_multiline
and tb_margin
and the array of tags contains the actual references to the logged scalars.