lingvo.base_trial module

Defines trials for parameter exploration.

class lingvo.base_trial.Trial(params)[source]

Bases: object

Base class for a trial.

classmethod Params()[source]

Default parameters for a trial.

property report_interval_seconds
property objective_metric_key
Name()[source]
OverrideModelParams(model_params)[source]

Modifies model_params according to trial params.

Through this method a Trial may tweak model hyperparams (e.g., learning rate, shape, depth, or width of networks).

Parameters

model_params – the original model hyperparams.

Returns

The modified model_params.

ShouldStop()[source]

Returns whether the trial should stop.

ReportDone(infeasible=False, infeasible_reason='')[source]

Report that the trial is completed.

ShouldStopAndMaybeReport(global_step, metrics_dict)[source]

Returns whether the trial should stop.

Parameters
  • global_step – The global step counter.

  • metrics_dict – If not None, contains the metric should be reported. If None, do nothing but returns whether the trial should stop.

_DoReportTrainingProgress(global_step, metrics_dict)[source]
ReportEvalMeasure(global_step, metrics_dict, checkpoint_path)[source]

Reports eval measurement and returns whether the trial should stop.

class lingvo.base_trial.NoOpTrial[source]

Bases: Trial

A Trial implementation that does nothing.

Name()[source]
OverrideModelParams(model_params)[source]

Modifies model_params according to trial params.

Through this method a Trial may tweak model hyperparams (e.g., learning rate, shape, depth, or width of networks).

Parameters

model_params – the original model hyperparams.

Returns

The modified model_params.

ShouldStop()[source]

Returns whether the trial should stop.

ReportDone(infeasible=False, infeasible_reason='')[source]

Report that the trial is completed.

ShouldStopAndMaybeReport(global_step, metrics_dict)[source]

Returns whether the trial should stop.

Parameters
  • global_step – The global step counter.

  • metrics_dict – If not None, contains the metric should be reported. If None, do nothing but returns whether the trial should stop.

ReportEvalMeasure(global_step, metrics_dict, checkpoint_path)[source]

Reports eval measurement and returns whether the trial should stop.

exception lingvo.base_trial.TunerManagedError[source]

Bases: BaseException

Base class for error that should be propagated to the tuner.

In base_runner.py, the training loop catchs all exceptions and treats unknown errors as failure. However, in some cases (e.g. PyGlove uses an EarlyStoppingError to signal early stopping that might take place at any moment), it requires the error to propagate to the tuner. This class is a base for such errors.