glassInit is a way to initialize the parameters of a neural network layer @pytorch. It is suitable for shortcut connections where tensor sizes need to be adjusted. The flow of information between forward and backward propagation is maximized while adjusting the tensor size.
Project description
glassInit
glassInit is a way to initialize the parameters of a neural network layer. It is suitable for shortcut connections where tensor sizes need to be adjusted. The flow of information between forward and backward propagation is maximized while adjusting the tensor size.
思路说明
在神经网络中构建快捷连接/跳跃连接时又是需要改变形状,如果直接使用卷积层/线性层等会因为其初始化方式影响连接中的梯度传播,而如果在各维度上分别使用插值缩放会导致明显的信息也会影响梯度传播. glassInit专用于快捷连接/跳跃连接中用于调整张量尺寸的层,它构建了一个插值矩阵实现在所有维度上一起插值,最大限度的保留了信息.
Install
pip install glassInit
Use
from glassInit import glassInit_
...
linear=torch.nn.Linear(512,2048,bias=False)
glassInit_(linear.weight,inDim=...,outDim=0,gain=None,zeroMean=True)
大多数时候不需要传入外部gain(默认为None),如果传入外部gain则内部gain不生效.输入元素数大于输出元素数时内部gain为1/sqrt(输入特征数/输出特征数),否则内部gain为1.
需根据矩阵各维度的作用填写inDim和outDim,最终加在一起的要填到inDim,输出时仍然分离的要填到outDim
举例来说卷积层的inChannel维度和kernels维度要填到inDim里,outChannel维度要填到outDim里
转置卷积要根据设定参数后的具体行为决定kernels维度要填到哪里,可以先写到outDim中尝试
如果zeroMean为False,返回矩阵将没有小于零的值,并且是插值矩阵.否则,返回矩阵将对插值矩阵逐元素随机取反.
HomePage
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
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 glassinit-0.0.2.tar.gz.
File metadata
- Download URL: glassinit-0.0.2.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2704483f886399c2d18f581da7e436e44faecf1d287e2e089c8a1f64e8a73d21
|
|
| MD5 |
24d01c84233c942e09b85464e96d4e46
|
|
| BLAKE2b-256 |
cde84b52717cda77df9f6c9222ba281ccdfd47236317cb56189f4f775e7b9f39
|
Provenance
The following attestation bundles were made for glassinit-0.0.2.tar.gz:
Publisher:
python-publish.yml on PsycheHalo/glassInit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glassinit-0.0.2.tar.gz -
Subject digest:
2704483f886399c2d18f581da7e436e44faecf1d287e2e089c8a1f64e8a73d21 - Sigstore transparency entry: 328932193
- Sigstore integration time:
-
Permalink:
PsycheHalo/glassInit@9b706f00d2fe1968f73e9294945fc083f516c5c1 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/PsycheHalo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9b706f00d2fe1968f73e9294945fc083f516c5c1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file glassinit-0.0.2-py3-none-any.whl.
File metadata
- Download URL: glassinit-0.0.2-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feef078b1d82dedc71eb81231db8604458266433df59157972e4509b32972cad
|
|
| MD5 |
ff767afe05bf0c78d3b144ac37478ccd
|
|
| BLAKE2b-256 |
45fafcb007bce5fb4de06155d03f2e88966d9f3a4c43e71fabe2712805a2a026
|
Provenance
The following attestation bundles were made for glassinit-0.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on PsycheHalo/glassInit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
glassinit-0.0.2-py3-none-any.whl -
Subject digest:
feef078b1d82dedc71eb81231db8604458266433df59157972e4509b32972cad - Sigstore transparency entry: 328932216
- Sigstore integration time:
-
Permalink:
PsycheHalo/glassInit@9b706f00d2fe1968f73e9294945fc083f516c5c1 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/PsycheHalo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@9b706f00d2fe1968f73e9294945fc083f516c5c1 -
Trigger Event:
release
-
Statement type: