question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update BaseOutputHandler to accept state attributes

See original GitHub issue

🚀 Feature

Here is the feature I would like to have, for example, with TensorboardLogger, but we can implement that for all exp tracking systems:

tb_logger = TensorboardLogger(log_dir="experiments/tb_logs")

tb_logger.attach_output_handler(
    trainer,
    event_name=Events.ITERATION_COMPLETED,
    tag="training",
    state_attrs=["alpha", "beta"]  # <->  trainer.state.alpha and trainer.state.beta
)

where state_attrs defines some attributes from trainer.state to log to TB.

Currently, this could be done as

tb_logger = TensorboardLogger(log_dir="experiments/tb_logs")

def trainer_state_logger(state_attrs, tag=None):

    def wrapper(engine, logger, event_name):
        assert engine == trainer

        global_step = engine.state.get_event_attrib_value(event_name)
        tag_prefix = f"{tag}/" if tag else ""
        for name in state_attrs:
            value = getattr(engine, name, None)
            if value is None:
                continue
            logger.writer.add_scalar(f"{tag_prefix}{name}", value, global_step)
    
tb_logger.attach(
    trainer,
    event_name=Events.ITERATION_COMPLETED,
    log_handler=trainer_state_logger(["alpha", "beta"], tag="training")
)

We would like to support state attributes types same as for metrics: See https://github.com/pytorch/ignite/blob/4d6d220e7be7a433cf2e16f92ca7cc6969ecea89/ignite/contrib/handlers/tensorboard_logger.py#L287-L296

This issues can be handled in several PRs that should implement the feature for the following exp tracking systems and loggers:

  • TensorBoard logger
  • Visdom logger
  • ClearML logger
  • Neptune logger
  • WandB logger
  • MLFlow logger
  • Polyaxon logger
  • tqdm logger

If you would like work on this issue, please comment out and say which part you would like to cover. A PR should contain new code, tests and documentation updates. Please see our contributing guide: https://github.com/pytorch/ignite/blob/master/CONTRIBUTING.md A draft PR can be sent and maintainers can help to iterate over the remaining tasks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Ishan-Kumar2commented, Aug 13, 2021

@vfdev-5 thanks for the reviews, looking forward to more contributions 😃

1reaction
vfdev-5commented, Aug 13, 2021

@Ishan-Kumar2 thanks a lot for your work on this issue. It is very helpful !

Read more comments on GitHub >

github_iconTop Results From Across the Web

State Objects - Home Assistant
Describes all there is to know about state objects in Home Assistant. ... This is not updated when there are only updated attributes....
Read more >
Updating a log stream's attributes - IBM
You can update certain attributes of a DASD-only or coupling facility log stream using either the IXGINVNT UPDATE service or the IXCMIAPU utility....
Read more >
On State Update Attribute for Unity with Odin Inspector
On State Update Attribute. OnStateUpdate provides an event callback when the property's state should be updated, when the StateUpdaters run on the property ......
Read more >
Dynamically update attributes of an object that depend on the ...
Yes, there is! It's called properties. Read Only Properties. class Test(object): def __init__(self,a,b): self.a = a self.b = b @property def ...
Read more >
Why update values in the state when they are ignored?
I would like to be able to ignore_changes and expect that not only are the ignored attributes not updated in future applies, but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found