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.
思路说明
把每组参数看作高维向量. 优化步骤被分割为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
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
704a8b07b1bf82d4c3597c8e59a3d788da7cfc199f98afda6324d669ed915464
|
|
| MD5 |
b3c99d54ad5324c1714ba8f2316d1799
|
|
| BLAKE2b-256 |
9c0bdb2f7559cd243aca5d38bfad18cfeccc6dfcc34269e2a2b6bcc6fdb37c09
|
Provenance
The following attestation bundles were made for afine-0.0.2a0.tar.gz:
Publisher:
python-publish.yml on PsycheHalo/Afine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
afine-0.0.2a0.tar.gz -
Subject digest:
704a8b07b1bf82d4c3597c8e59a3d788da7cfc199f98afda6324d669ed915464 - Sigstore transparency entry: 163209670
- Sigstore integration time:
-
Permalink:
PsycheHalo/Afine@cefa3c7f6374f2ef01b398239046cabfd999ee52 -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/PsycheHalo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cefa3c7f6374f2ef01b398239046cabfd999ee52 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1d3973ca792a1d557774275b38e64a08bb18cd99bac7a458e737e3c702227ad
|
|
| MD5 |
ffe866d19d1b454b06d50dc8263b98b2
|
|
| BLAKE2b-256 |
38253972920a7e70facf5309d7e7225da13c84e0f58bcde4d53b633daef02035
|
Provenance
The following attestation bundles were made for Afine-0.0.2a0-py3-none-any.whl:
Publisher:
python-publish.yml on PsycheHalo/Afine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
afine-0.0.2a0-py3-none-any.whl -
Subject digest:
d1d3973ca792a1d557774275b38e64a08bb18cd99bac7a458e737e3c702227ad - Sigstore transparency entry: 163209672
- Sigstore integration time:
-
Permalink:
PsycheHalo/Afine@cefa3c7f6374f2ef01b398239046cabfd999ee52 -
Branch / Tag:
refs/tags/v0.0.2-alpha - Owner: https://github.com/PsycheHalo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cefa3c7f6374f2ef01b398239046cabfd999ee52 -
Trigger Event:
release
-
Statement type: