pub trait Profiler<Model, Opt, Input, Output> {
type EvalMetrics;
// Required methods
fn train(
&self,
model: &mut Model,
optimizer: &mut Opt,
x: &Input,
y: &Output,
) -> Result<(TrainMetrics, Self::EvalMetrics), ProfilerError>;
fn profile_evaluation(
&self,
model: &mut Model,
x: &Input,
y: &Output,
) -> Result<Self::EvalMetrics, ProfilerError>;
}Expand description
Trait for profiling and benchmarking machine learning models during training and evaluation.
This trait defines methods for collecting performance metrics during model training and evaluation. It allows for consistent measurement of training time and model performance metrics across different model types and optim strategies.
§Type Parameters
Model- The machine learning model type being profiledOpt- The optimizer type used for trainingInput- The input data type (features)Output- The output data type (targets/labels)
Required Associated Types§
Sourcetype EvalMetrics
type EvalMetrics
The type of evaluation metrics returned by the profiler
Required Methods§
Sourcefn train(
&self,
model: &mut Model,
optimizer: &mut Opt,
x: &Input,
y: &Output,
) -> Result<(TrainMetrics, Self::EvalMetrics), ProfilerError>
fn train( &self, model: &mut Model, optimizer: &mut Opt, x: &Input, y: &Output, ) -> Result<(TrainMetrics, Self::EvalMetrics), ProfilerError>
Profiles the training process of a model, collecting training time and evaluation metrics.
This method measures the time taken for training while also computing performance metrics on the provided data.
§Arguments
model- Mutable reference to the model being trainedoptimizer- Mutable reference to the optimizer used for trainingx- Reference to input featuresy- Reference to output targets
§Returns
A tuple containing training metrics (including training time) and evaluation metrics specific to the model type, or a ProfilerError if an error occurs during profiling.
Sourcefn profile_evaluation(
&self,
model: &mut Model,
x: &Input,
y: &Output,
) -> Result<Self::EvalMetrics, ProfilerError>
fn profile_evaluation( &self, model: &mut Model, x: &Input, y: &Output, ) -> Result<Self::EvalMetrics, ProfilerError>
Profiles the evaluation process of a model, computing performance metrics.
This method evaluates the model on the provided data and returns metrics specific to the model type.
§Arguments
model- Mutable reference to the model being evaluatedx- Reference to input featuresy- Reference to output targets
§Returns
Evaluation metrics specific to the model type, or a ProfilerError if an error occurs during evaluation.