Skip to content

How to best access a specific gradient transformation state? #278

Answered by mkunesch
andsteing asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Thanks a lot for the question!

As far as I know there is no utility for this at the moment in optax, but I also wouldn't consider it an anti-pattern (e.g. I think it's the best way to log variables from the optimizer state #206).

For a simple optimizer state (and many are simple) I think it's fine to use the index. For more complicated chains I think it can be less readable to have e.g. state[2].

What would the nested index look like in your case? Would it only be known at runtime?

The reason I'm asking is that if it's a matter of readability, it might be possible to improve this without introducing a utility for searching within an optimizer state.

Thanks a lot for the question again!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@andsteing
Comment options

@mkunesch
Comment options

@andsteing
Comment options

Answer selected by andsteing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants