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. This way, the gradient clipping thresholds automatically adapt to the gradient statistics and become equivariant with respect to scaling the gradients. This makes finding suitable clipping thresholds much easier (usually, the default thresholds are good to go). Furthermore, by directly utilizing the internal state variables of Adam, AdamWClip implements adaptive gradient clipping without an additional memory footprint.

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.0.tar.gz (3.0 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.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: adamwclip-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 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.0.tar.gz
Algorithm Hash digest
SHA256 b4bcecd34f847efa7d0251ea47e0ee78c496553fe78c86eab64eb01ef963ab25
MD5 c887601e09a2f264449c6d652b5a0cae
BLAKE2b-256 79b0b39b1e870db4df10b73c626c4f74c49b609249b0e185b779a314f9ff00b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: adamwclip-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de6cfc81fa54dd66ec4477c9c958acb1175aef26cc687cc3be3d80ecc7be48f5
MD5 cb5d384790f930a0d48c65abbc09730a
BLAKE2b-256 b8d44ed68e47ee044a35628ec7ea8e8b2f8635eada8189c3f896c52691bdb41a

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