[Bug] WandbVisBackend can't set the X‑axis to epoch, because LoggerHook does not consistently pass the epoch value

Open
#1,692 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #1693 by @dgexplores — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
observability

Research direction

Start by reading LoggerHook, especially after_val_epoch, and trace how its tag is passed to runner.visualizer.add_scalars with WandbVisBackend. Confirm the epoch value is included consistently in the logged tag, then verify that configuring the Wandb metric with epoch as the X-axis works without breaking validation logging.

Written by the indexing model from the issue text.

Description

bug
Prerequisite
Environment

v0.11.0r3

Reproduces the problem - code sample
        define_metric_cfg = [dict(name='epoch', hidden=True)]
        cfg.visualizer.vis_backends.append(dict(type='WandbVisBackend', init_kwargs=wandb_init_kwargs, define_metric_cfg=define_metric_cfg))
Reproduces the problem - command or script

None

Reproduces the problem - error message
Image
Additional information

solution

@HOOKS.register_module()
class LoggerHook(Hook):
....
    def after_val_epoch(self,...
            if (isinstance(runner._train_loop, dict)
                    or runner._train_loop is None):
                epoch = 0
            else:
                epoch = runner.epoch
----------------------
            tag['epoch'] = epoch # add this line can fix it
----------------------
            runner.visualizer.add_scalars(
                tag, step=epoch, file_path=self.json_log_path)
Dominant language
Python
Stars
1.5k
Forks
470
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from open-mmlab/mmengine

All issues in open-mmlab/mmengine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.