Skip to main content

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: image

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

adamr-0.0.1.tar.gz (316.5 kB view details)

Uploaded Source

Built Distribution

adamr-0.0.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file adamr-0.0.1.tar.gz.

File metadata

  • Download URL: adamr-0.0.1.tar.gz
  • Upload date:
  • Size: 316.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for adamr-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0a7ff02de1bbbc2cd9100cf36ae5ac5f1d975a4e2f0046b8e21d35d718a06d7e
MD5 9eb771a80a51279a4ebb1de020dac261
BLAKE2b-256 497e51f6a38949fd65e89f0215ea79ad7288abb0333cd885815f5f2ab90e5c60

See more details on using hashes here.

File details

Details for the file adamr-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: adamr-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for adamr-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9adcedacf0cf64d067f84ab1e91af99dc46e9780ae07a8cd99d350dff238d035
MD5 b80717a7155e816b687b609272f699e0
BLAKE2b-256 0b8f20a037432c9b27ed9e781ab410f7a03341a53f51b2a94572c90a1f0ba82a

See more details on using hashes here.

Supported by

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