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.

Stateless Transformation

See original GitHub issue

Right now, there’s some boilerplate for defining simple gradient transformations. If a user wants to implement custom weight decay, clipping, constraints, etc without any state, they still have to define a nested function with an init that does nothing, and handle the empty state.

I think it’d be convenient to provide a stateless transformation that accepts a function to apply to the updates and params. We can also do the jax.tree_multimap for the user by default.

weight_decay = optax.stateless(lambda g, p: g + 0.1 * p)

If the user wants to define a function that does the tree_multimap themselves:

def my_function(updates, params):
    return jax.tree_multimap(lambda g, p: ..., updates, params)

optim = optax.stateless(my_function, on_leaves=False)

In my view, this is a very clean way to implement simple stateless transformations. I think the on_leaves argument could use a better name, though. I’d be happy to implement this if it sounds reasonable.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
n2cholascommented, Nov 17, 2021

No more action needed on your side @mtthss, I’ll work on this over the weekend!

1reaction
mtthsscommented, Nov 5, 2021

Great, thanks @n2cholas! And apologies for the slow turnaround on this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stateful/stateless transformations - Big Data Analytics with ...
In a stateless transformation, whether or not each microbatch of data is processed does not depend on the previous data batches, so each...
Read more >
Stateful/stateless transformations | Scala and Spark for Big ...
In Stateless transformations, the processing of each micro-batch of data does not depend on the previous batches of data. Thus, this is a...
Read more >
Stateless Transforms - Hazelcast Jet
Stateless transforms are the bread and butter of a data pipeline: they transform the input into the correct shape that is required by...
Read more >
7.6 Spark Streaming Tutorial | Stateless vs Stateful ... - YouTube
Then we will see how stateful and stateless transformations are done in spark streaming. how these are useful After completing the Apache ...
Read more >
DS320.33 Spark Streaming: Stateless Transformations
#DataStaxAcademy #DS320 DS320.33 Spark Streaming: Stateless Transformations In this course, you will learn how to effectively and ...
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