Adam with weight recovery optimizer for pytorch
Project description
AdamR
Adam with weight Recovery optimizer
TL;DR
AdamW tends to decay parameters towards zero, which makes the model "forget" the pretrained parameters during finetuning. Instead, AdamWR tries to recover parameters towards pretrained values during finetuning.
Have a try
Just like other PyTorch optimizers,
from adamr import AdamR
from xxx import SomeModel, SomeData, SomeDevice, SomeLoss
model = SomeModel()
dataloader = SomeData()
model.to(SomeDevice)
adamr = AdamR(
model.parameters(),
lr=1e-5,
betas=(0.9, 0.998), # Adam's beta parameters
eps=1e-8,
weight_recovery=0.1
)
loss_fn = SomeLoss()
for x, y in dataloader:
adamwr.zero_grad()
y_bar = model(x)
loss = loss_fn(y_bar, y)
loss.backward()
adamr.step()
Algorithm
TODO: improve the readability
Here is a paper snippet:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
adamr-0.0.2.tar.gz
(316.8 kB
view details)
Built Distribution
adamr-0.0.2-py3-none-any.whl
(10.8 kB
view details)
File details
Details for the file adamr-0.0.2.tar.gz
.
File metadata
- Download URL: adamr-0.0.2.tar.gz
- Upload date:
- Size: 316.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68eef97e26377a0d5791c2a587b30abc1a01f6de8ce9436e6f60d3db4c67a5a7 |
|
MD5 | 4ee07d3e86d5233c1d263718f675daa9 |
|
BLAKE2b-256 | 70c7cfa5365a9de0267cb210c756cf2707198cc30f99751bbbe22693e4845ed5 |
File details
Details for the file adamr-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: adamr-0.0.2-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f773611fb0058eb288a9751aba442daa9422d46e63411d93c0caa01d9c5e0ea5 |
|
MD5 | 9525025b97b2a397fefc1ccb20c10c8f |
|
BLAKE2b-256 | d872f92944fbd66d7c4d71cd3d51e1192051f4600ee03ddc9b19a637ad3a9d62 |