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.2.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.2-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: afine-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e1357e4e9483e80f35c3bee6daa1ef6ab488656391671a50d0691063f6a0b4aa
MD5 b33f28d5411e6e1237f95f9a458d9a83
BLAKE2b-256 aa547cbb388146f4d4aceda6a2285e8ab8e1f58556996c86b21ccb6b055ad23e

See more details on using hashes here.

Provenance

The following attestation bundles were made for afine-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: Afine-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 651a8dd60ccc5362c60624577e6829b92750d0e31bf2087fb3247651be806ee5
MD5 c04008707e03985778636c6be0877da0
BLAKE2b-256 2253220ec07932588d5392f0bd6ffa69fc725863d34e30cb91eceaa193778af8

See more details on using hashes here.

Provenance

The following attestation bundles were made for Afine-0.0.2-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