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 doesn't require additional memory (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. If set to None, this optimizer behaves exactly like AdamW (default: 3)
- clip_grad_min: minimum value for the adaptive gradient clipping threshold (default: 1e-10)
- clip_grad_warm_up: (Optional) number of initial update steps without gradient clipping to obtain more reasonable gradient statistics at the beginning (default: 0)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adamwclip-0.1.3.tar.gz.
File metadata
- Download URL: adamwclip-0.1.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4558e5474d45509f23076bebd5c3da7209229007efd0d1612823776f89b60db
|
|
| MD5 |
cf8b142d3a48e8537c8da7c54f897aba
|
|
| BLAKE2b-256 |
7b80beaae01b0a91bf3f25c07e04280a190df17aa1378a2fd574b0c0927b9ecb
|
File details
Details for the file adamwclip-0.1.3-py3-none-any.whl.
File metadata
- Download URL: adamwclip-0.1.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24f89489079f81d68b02c7327a509736c39295506783ca7179148b02cbdbea7c
|
|
| MD5 |
eee697b298034797e711cf4c771e6d81
|
|
| BLAKE2b-256 |
8f848508faa008fda36826455383bb3d9639fab18161142fea0284f52c164848
|