Documentation
¶
Overview ¶
Package commandline contains convenience UI training tools for the command line.
Index ¶
- Constants
- Variables
- func AttachProgressBar(loop *train.Loop)
- func CreateContextSettingsFlag(ctx *context.Context, flagName string) *string
- func ParseContextSettings(ctx *context.Context, settings string) (paramsSet []string, err error)
- func ReportEval(trainer *train.Trainer, datasets ...train.Dataset) error
- func SprintContextSettings(ctx *context.Context) string
- func SprintModifiedContextSettings(ctx *context.Context, paramsSet []string) string
Constants ¶
const ProgressBarName = "gomlx.ml.train.commandline.progressBar"
Variables ¶
var ProgressbarStyle = progressbar.ThemeASCII
ProgressbarStyle to use. Defaults to ASCII version. Consider progressbar.ThemeUnicode for a prettier version. But it requires some of the graphical symbols to be supported.
Functions ¶
func AttachProgressBar ¶
AttachProgressBar creates a commandline progress bar and attaches it to the Loop, so that everytime Loop is run it will display a progress bar with progression and metrics.
The associated data will be attached to the train.Loop, so nothing is returned.
func CreateContextSettingsFlag ¶
CreateContextSettingsFlag create a string flag with the given flagName (if empty it will be named "set") and with a description of the current defined parameters in the context `ctx`.
The flag should be created before the call to `flags.Parse()`.
Example usage:
func main() { ctx := createDefaultContext() settings := commandline.CreateContextSettingsFlag(ctx, "") flag.Parse() err := commandline.ParseContextSettings(ctx, *settings) if err != nil { panic(err) } fmt.Println(commandline.SprintContextSettings(ctx)) ... }
func ParseContextSettings ¶
ParseContextSettings from settings -- typically the contents of a flag set by the user. The settings are a list separated by ";": e.g.: "param1=value1;param2=value2;...".
All the parameters "param1", "param2", etc. must be already set with default values in the context `ctx`. The default values are also used to set the type to which the string values will be parsed to.
It updates `ctx` parameters accordingly and returns an error in case a parameter is unknown or the parsing failed.
Note, one can also provide a scope for the parameters: "layer_1/l2_regularization=0.1" will work, as long as a default "l2_regularization" is defined in `ctx`.
For integer types, "_" is removed: it allows one to enter large numbers using it as a separator, like in Go. E.g.: 1_000_000 = 1000000.
See the example in CreateContextSettingsFlag, which will create a flag for the settings.
Example usage:
func main() { ctx := createDefaultContext() settings := commandline.CreateContextSettingsFlag(ctx, "") flag.Parse() err := commandline.ParseContextSettings(ctx, *settings) if err != nil { panic(err) } fmt.Println(commandline.SprintContextSettings(ctx)) ... }
func ReportEval ¶
ReportEval reports on the command line the results of evaluating the datasets using trainer.Eval.
func SprintContextSettings ¶
SprintContextSettings pretty-print values for the current hyperparameters settings into a string.
Types ¶
This section is empty.