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.

Flexible access to state

See original GitHub issue

The introduction of State (#80, #83) which is passed to event handlers is very welcome as it is a critical requirement. The flexibility with which state is passed around, however, could still be improved. Currently:

  1. Event handlers can only access the state of the engine issuing the event.
  2. There is no access to the state in the training and validation functions.

An argument against making state a member of the engine was that in so not doing, the state is explicitly ephemeral. However, this enforces the assumption that an engines state should only every be accessed by that engine’s event handlers.

One example of where (1) is an obstacle is on attempting to identify current epoch during training. It is useful to read the current epoch on completion of validation when saving a checkpoint, in order to record the epoch. However, the current epoch is a state attribute of the training engine; currently, there is no way to access that state, except when handling a signal emitted by the training engine.

It would be convenient to have state exposed in Trainer and Evaluator as self.state so that a user may have direct access to it, outside of callbacks that are specific to the calling engine.

If state is thus exposed, it may be cleaner to also not pass engine state by default to handlers; the user could pass any state (eg. trainer.state) through the *args or **kwargs of add_event_handler, instead – if some state is needed by the event handler.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonkrisscommented, Mar 19, 2018

Just to summarize, my vote is for the following changes:

  1. attach state to engine
  2. pass engine as the only argument to all event handlers
  3. pass engine, batch to update functions

What do you all think?

1reaction
veugenecommented, Mar 19, 2018

Do you have a use-case for when you’d want to access the state in the update function?

That really has to do with the discussion in #118 which it appears you’ve seen now.

would you be able to send a PR?

Yes, it shouldn’t take long once I get around to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flexible access Definition - Law Insider
Flexible access means taking a cash amount over the tax-free lump sum from a flexi- access drawdown account; taking an uncrystallised funds pension...
Read more >
State Flexibility Overview - MACPAC
Under Medicaid's federal-state partnership, states currently have flexibility to design and administer their Medicaid programs; policy levers include.
Read more >
Federal Guidance Details Uses of Flexible Aid for State and ...
On May 10, 2021, the U.S. Treasury Department released guidance describing the uses and limitations for the flexible funding appropriated to ...
Read more >
Current Flexibility in Medicaid: An Overview of Federal ... - KFF
Each state Medicaid program is unique, reflecting states' use of existing flexibility and waiver authority to design their programs to meet ...
Read more >
flexible funding for transit accessview more topics
However, some State Departments of Transportation (DOTs), cities, and Tribes may not use these funds for small-scale safety and access improvements due to ......
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