Skip to main content

AdamWClip is an optimizer that extends AdamW with adaptive gradient clipping.

Project description

AdamWClip: AdamW with adaptive gradient clipping

AdamWClip is an optimizer that extends AdamW with adaptive gradient clipping. It automatically adapts the gradient clipping thresholds to the gradient statistics of each parameter resulting in equivariant thresholds with respect to scaling the gradients. This makes finding suitable clipping thresholds much easier (usually, the default threshold of AdamWClip is good to go). Furthermore, by directly utilizing the internal state variables of Adam, AdamWClip implements adaptive gradient clipping without an additional memory footprint (and only a marginal computational overhead).

Useage

To use AdamWClip in your pytorch project, simply run the following:

%pip install AdamWClip
from AdamWClip import AdamWClip
...
optimizer = AdamWClip(model.parameters(),*args)

On top of the standard parameters from AdamW, AdamWClip offers the following additional parameters:

  • clip_grad_adapt: adaptive gradient clipping threshold in terms of standard deviations of the clipped gradient distribution (default: 3)
  • clip_grad_min: minimum value for the adaptive gradient clipping threshold (default: 0.01)
  • clip_grad_warm_up: Number of initial update steps without gradient clipping to obtain reasonable gradient statistics at the beginning (default: 10)

In most instances, the default values should be fine.

If this optimizer becomes useful to you, please consider citing this repository :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adamwclip-0.1.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adamwclip-0.1.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file adamwclip-0.1.1.tar.gz.

File metadata

  • Download URL: adamwclip-0.1.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for adamwclip-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45ce229b0353f2226ba179373d1915dfde9d4365bf1becad89999a61a553f3bf
MD5 ef8a0b81a37f285dff12813c54048be0
BLAKE2b-256 e345e55f9322d82ec40be95b0dc8f9225169b63d60248ad8e140abd45c01304f

See more details on using hashes here.

File details

Details for the file adamwclip-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: adamwclip-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for adamwclip-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3c15fbcd52d987f04344f5e45a301c4bb4ec02ed58a1e73a96e5a8f11e35f6a
MD5 6dc384ee2c35225df7fb8cb0cdc568f2
BLAKE2b-256 6749c0b3b2c13c5179714e7f5be6adf038e7323199513195a108a35c5c3de220

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page