(self, metadata)
Log benchmarks performance.
Log benchmarks performance.
Log benchmarks performance .
def on_train_begin(self, metadata):
        """Log benchmarks performance."""
        n_epochs = metadata.get('n_epochs')

        if self.log_benchmarks:
            try:
                df = self.run.history.metrics_per_epoch(-1)  # only benchmarks
                for bm_name in df['model'].unique():
                    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()}

                    bm_writer = SummaryWriter(self.log_dir / bm_name)

                    for metric_name, metric_value in metrics.items():
                        for global_step in range(n_epochs):
                            bm_writer.add_scalar(metric_name, metric_value, global_step=global_step)

            except KeyError:
                return
def on_train_begin ( self , metadata ) : n_epochs = metadata . get ( 'n_epochs' ) if self . log_benchmarks : try : df = self . run . history . metrics_per_epoch ( - 1 ) # only benchmarks for bm_name in df [ 'model' ] . unique ( ) : 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 ( ) } bm_writer = SummaryWriter ( self . log_dir / bm_name ) for metric_name , metric_value in metrics . items ( ) : for global_step in range ( n_epochs ) : bm_writer . add_scalar ( metric_name , metric_value , global_step = global_step ) except KeyError : return