def test_lightning_logger_base_merge_dicts_deprecation_warning(): with pytest.deprecated_call( match= "The `pytorch_lightning.loggers.base.merge_dicts` is deprecated in v1.7 and will be removed in v1.9." ): d1 = {"a": 1.7, "b": 2.0, "c": 1, "d": {"d1": 1, "d3": 3}} d2 = {"a": 1.1, "b": 2.2, "v": 1, "d": {"d1": 2, "d2": 3}} d3 = {"a": 1.1, "v": 2.3, "d": {"d3": 3, "d4": {"d5": 1}}} dflt_func = min agg_funcs = {"a": min, "v": max, "d": {"d1": sum}} logger_base.merge_dicts([d1, d2, d3], agg_funcs, dflt_func)
def validation_epoch_end(self, val_metrics): """ Process and log accumulated validation results in one epoch """ val_metrics_epoch = merge_dicts(val_metrics) self.log_dict({ f'val_metrics/{k}': metric for k, metric in val_metrics_epoch.items() }) # update hparams metrics self.hparam_metrics = { f'hparam_metrics/{k}': val_metrics_epoch[k] for k in self.hparams.meta.hparam_metrics }
def validation_epoch_end(self, outputs): self._generate_and_log_text_samples() validation_epoch_result = merge_dicts( outputs, default_func=lambda x: torch.stack(x).mean()) return validation_epoch_result
def validation_epoch_end(self, val_step_results: Sequence): validation_epoch_result = merge_dicts( dicts=val_step_results, default_func=lambda x: torch.stack(x).mean().item()) return validation_epoch_result