(self, metadata)
Log hyperparameters and potentially benchmarks performance.
Log hyperparameters and potentially benchmarks performance.
Log hyperparameters and potentially benchmarks performance .
def on_train_begin(self, metadata):
        """Log hyperparameters and potentially benchmarks performance."""
        with ChangeWorkingDirectory(self.mlflow_path):
            # log some metadata
            if self.experiment_name is not None:
                mlflow.set_experiment(self.experiment_name)

            with mlflow.start_run(run_name=self.run_name, run_id=self._run_id):
                # if run_id is not None then run_name is ignored
                self._run_id = mlflow.active_run().info.run_id
                params = {
                    'device': self.run.device,
                    'dtype': self.run.dtype,
                    'train_dataloader': self.run.train_dataloader.__class__.__name__
                }
                params.update(self.run.train_dataloader.hparams)
                params.update(self.run.network.hparams)

                mlflow.log_params(params)

            if self.log_benchmarks:
                try:
                    df = self.run.history.metrics_per_epoch(-1)  # only benchmarks
                    for bm_name in df['model'].unique():
                        with mlflow.start_run(run_name=bm_name):
                            temp_df = df[df['model'] == bm_name]
                            metrics = {'_'.join(list(map(lambda x: str(x), k))): v for k, v in
                                       temp_df.groupby(['dataloader', 'metric', 'lookback'])['value'].mean().items()}

                            mlflow.log_metrics(metrics, step=0)
                            mlflow.log_metrics(metrics, step=10)
                except KeyError:
                    return
def on_train_begin ( self , metadata ) : with ChangeWorkingDirectory ( self . mlflow_path ) : # log some metadata if self . experiment_name is not None : mlflow . set_experiment ( self . experiment_name ) with mlflow . start_run ( run_name = self . run_name , run_id = self . _run_id ) : # if run_id is not None then run_name is ignored self . _run_id = mlflow . active_run ( ) . info . run_id params = { 'device' : self . run . device , 'dtype' : self . run . dtype , 'train_dataloader' : self . run . train_dataloader . __class__ . __name__ } params . update ( self . run . train_dataloader . hparams ) params . update ( self . run . network . hparams ) mlflow . log_params ( params ) if self . log_benchmarks : try : df = self . run . history . metrics_per_epoch ( - 1 ) # only benchmarks for bm_name in df [ 'model' ] . unique ( ) : with mlflow . start_run ( run_name = bm_name ) : temp_df = df [ df [ 'model' ] == bm_name ] metrics = { '_' . join ( list ( map ( lambda x : str ( x ) , k ) ) ) : v for k , v in temp_df . groupby ( [ 'dataloader' , 'metric' , 'lookback' ] ) [ 'value' ] . mean ( ) . items ( ) } mlflow . log_metrics ( metrics , step = 0 ) mlflow . log_metrics ( metrics , step = 10 ) except KeyError : return