Skip to main content

Afine is a gradient based PyTorch optimizer.

Project description

Afine Optimizer

An optimizer that is superior to Adam. Based on @PyTorch

The training is more stable and reaches a more elegant optimal solution faster.

image image

思路说明

把每组参数看作高维向量. 优化步骤被分割为3个过程: 旋转、缩放、平移. 使用三个学习率分别控制三个过程的调整量.

1.旋转

  • 计算梯度对参数向量方向的影响.
  • 根据旋转的稳定程度调整旋转的作用强度.
  • 使用近似旋转改变参数向量方向而不改变模长.

2.缩放

  • 计算梯度对参数向量模长的影响.
  • 根据模长改变的稳定程度调整缩放的作用强度.
  • 权重衰减作用于这一步: 使用ArcSinh函数对向量放大带来阻力而促进向量缩小.
  • 应用缩放变换.

3.平移

  • 旋转和缩放对零向量无作用, 为使零初始化和模长较小的向量也能被训练, 需加入平移.
  • 此处的平移带有惯性,且平移量与梯度稳定程度有关.

Demo程序

demo程序在test.py文件中,直接运行即可得到此页面中Affine与RAdam的对比图.(依赖visdom) demo中构建了一个神经网络用简陋的方式对一个包含动态随机参数的公式生成的周期性曲线进行预测.

Install

pip install afine

Use

from Afine import Afine
...
optimizer=Affine(moduel.parameters(),lr_rotate = lr_rotate,lr_scale = lr_scale,lr_base = lr_base,weight_decay=weight_decay)

HomePage

https://github.com/PsycheHalo/Afine/

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

afine-0.0.2a0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

Afine-0.0.2a0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file afine-0.0.2a0.tar.gz.

File metadata

  • Download URL: afine-0.0.2a0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for afine-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 704a8b07b1bf82d4c3597c8e59a3d788da7cfc199f98afda6324d669ed915464
MD5 b3c99d54ad5324c1714ba8f2316d1799
BLAKE2b-256 9c0bdb2f7559cd243aca5d38bfad18cfeccc6dfcc34269e2a2b6bcc6fdb37c09

See more details on using hashes here.

Provenance

The following attestation bundles were made for afine-0.0.2a0.tar.gz:

Publisher: python-publish.yml on PsycheHalo/Afine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file Afine-0.0.2a0-py3-none-any.whl.

File metadata

  • Download URL: Afine-0.0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for Afine-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1d3973ca792a1d557774275b38e64a08bb18cd99bac7a458e737e3c702227ad
MD5 ffe866d19d1b454b06d50dc8263b98b2
BLAKE2b-256 38253972920a7e70facf5309d7e7225da13c84e0f58bcde4d53b633daef02035

See more details on using hashes here.

Provenance

The following attestation bundles were made for Afine-0.0.2a0-py3-none-any.whl:

Publisher: python-publish.yml on PsycheHalo/Afine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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