plotly

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package plotly uses GoNB plotly support (`github.com/janpfeifer/gonb/gonbui/plotly`) to plot both on dynamic plots while training or to quickly plot the results of a previously saved plot results in a checkpoints directory.

In either case it allows adding baseline plots of previous checkpoints.

The advantage of `plotly` over `margaid` plots is that it uses Javascript to make the plot interactive (it displays information on mouse hover).

The disadvantage is that saving doesn't work, because of the javascript nature.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlotConfig

type PlotConfig struct {

	// EvalDatasets registered to be used during evaluation when dynamically capturing points during training.
	EvalDatasets []train.Dataset
	// contains filtered or unexported fields
}

PlotConfig hold the configuration object that will generate the plot. Create it with New.

func New

func New() *PlotConfig

New creates a new PlotConfig, that can be used to generate plots.

func (*PlotConfig) AddPoint

func (pc *PlotConfig) AddPoint(pt plots.Point)

AddPoint add one point to the plots.

Usually not called directly, instead use [LoadCheckpointData] or [Dynamic], which will attach to a training loop and call this automatically.

func (*PlotConfig) Dynamic

func (pc *PlotConfig) Dynamic(datasets ...train.Dataset) *PlotConfig

Dynamic sets plot to be dynamically updated and new data comes in. It's a no-op if not running in a GoNB notebook.

`datasets` is a list of datasets to be evaluated when collecting metrics for plotting.

It should be followed by a call to [ScheduleExponential] or [SechedulePeriodic] (or both) to schedule capturing points to plot, and [WithCheckpoint] to save the captured points.

It returns itself to allow cascading configuration method calls.

func (*PlotConfig) DynamicPlot

func (pc *PlotConfig) DynamicPlot(final bool)

DynamicPlot is called everytime a new metrics comes in, if configured for dynamic updates. Usually, not called directly by the user. Simply use [Dynamic] and schedule updates and this function will be called automatically.

If `final` is true, it clears the transient area, and it plots instead in the definitive version.

func (*PlotConfig) DynamicSampleDone

func (pc *PlotConfig) DynamicSampleDone(incomplete bool)

DynamicSampleDone is called after all the data points recorded for this sample (evaluation at a time step). The value `incomplete` is set to true if any of the evaluations are NaN or infinite.

If in a notebook, this would trigger a redraw of the plot.

It implements [plot.Plotter]

func (*PlotConfig) LoadCheckpointData

func (pc *PlotConfig) LoadCheckpointData(dataDirOrFile string, filters ...PointFilter) error

LoadCheckpointData loads plotting data from a checkpoint path. Notice this only works if the model was trained with plotting, with the metrics saved into the file `training_plot_points.json` (plots.TrainingPlotFileName). Notice that if `dataDirOrFile` is a file it reads from that instead.

The `filters` are an optional list of filters to apply (in order) to each of the points read: it allows points to be modified arbitrarily -- in particular useful to change names (like adding a prefix) of metrics or metrics types.

Each filter can also eliminate points by returning false -- only points for which filters returned true are included.

func (*PlotConfig) Plot

func (pc *PlotConfig) Plot() error

Plot all figures with current data. If not in a notebook, this is a no-op.

func (*PlotConfig) ScheduleExponential

func (pc *PlotConfig) ScheduleExponential(loop *train.Loop, startStep int, stepFactor float64) *PlotConfig

ScheduleExponential collection of plot points, starting at `startStep` and with an increasing step factor of `stepFactor`. Typical values where could be 100 and 1.1.

It returns itself to allow cascading configuration method calls.

func (*PlotConfig) ScheduleNTimes

func (pc *PlotConfig) ScheduleNTimes(loop *train.Loop, numPoints int) *PlotConfig

ScheduleNTimes of collection of plot points.

It returns itself to allow cascading configuration method calls.

func (*PlotConfig) WithCheckpoint

func (pc *PlotConfig) WithCheckpoint(checkpointDir string) *PlotConfig

WithCheckpoint uses the `checkpointDir` both to load data points and to save any new data points. Usually, used with PlotConfig.Dynamic.

New data-points are saved asynchronously -- not to slow down training, with the downside of potentially having I/O issues reported asynchronously.

It returns itself to allow cascading configuration method calls.

type PointFilter

type PointFilter func(p *plots.Point) bool

PointFilter can change any plots.Point arbitrarily. If it returns false means the point should be dropped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL