Name | glassInit JSON |
Version |
0.0.6
JSON |
| download |
home_page | None |
Summary | 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. |
upload_time | 2025-08-06 13:26:50 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
glassinit
initialize
shortcut
pytorch
ai
neural
nn
connections
skip connections
res
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# 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
```bash
pip install glassInit
```
## Use
```python
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. 否则内部gain为sqrt(输出元素数/输入元素数)
需根据矩阵各维度的作用填写inDim和outDim,最终加在一起的要填到inDim,输出时仍然分离的要填到outDim
举例来说卷积层的inChannel维度和kernels维度要填到inDim里,outChannel维度要填到outDim里
转置卷积要根据设定参数后的具体行为决定kernels维度要填到哪里,可以先写道inDim中尝试
如果zeroMean为False,返回矩阵将没有小于零的值,并且是插值矩阵.否则,返回矩阵将对插值矩阵逐元素随机取反.
如果输入元素数大于输出元素数或关闭稀疏,矩阵实现线性插值,否则是插0插值.两种插值均为循环边界条件.
## HomePage
<https://github.com/PsycheHalo/glassInit/>
Raw data
{
"_id": null,
"home_page": null,
"name": "glassInit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "glassInit, initialize, shortcut, PyTorch, AI, neural, NN, connections, Skip Connections, Res",
"author": null,
"author_email": "Psyche Halo <Psyche@WinsGod.com>",
"download_url": "https://files.pythonhosted.org/packages/8c/55/9afba18ef33e97dc6ce010e9a65654512b30dd1b0dbf3cf9765eea1bac29/glassinit-0.0.6.tar.gz",
"platform": null,
"description": "# glassInit\nglassInit 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. \n\n## \u601d\u8def\u8bf4\u660e\n\u5728\u795e\u7ecf\u7f51\u7edc\u4e2d\u6784\u5efa\u5feb\u6377\u8fde\u63a5/\u8df3\u8dc3\u8fde\u63a5\u65f6\u53c8\u662f\u9700\u8981\u6539\u53d8\u5f62\u72b6,\u5982\u679c\u76f4\u63a5\u4f7f\u7528\u5377\u79ef\u5c42/\u7ebf\u6027\u5c42\u7b49\u4f1a\u56e0\u4e3a\u5176\u521d\u59cb\u5316\u65b9\u5f0f\u5f71\u54cd\u8fde\u63a5\u4e2d\u7684\u68af\u5ea6\u4f20\u64ad,\u800c\u5982\u679c\u5728\u5404\u7ef4\u5ea6\u4e0a\u5206\u522b\u4f7f\u7528\u63d2\u503c\u7f29\u653e\u4f1a\u5bfc\u81f4\u660e\u663e\u7684\u4fe1\u606f\u4e5f\u4f1a\u5f71\u54cd\u68af\u5ea6\u4f20\u64ad. glassInit\u4e13\u7528\u4e8e\u5feb\u6377\u8fde\u63a5/\u8df3\u8dc3\u8fde\u63a5\u4e2d\u7528\u4e8e\u8c03\u6574\u5f20\u91cf\u5c3a\u5bf8\u7684\u5c42,\u5b83\u6784\u5efa\u4e86\u4e00\u4e2a\u63d2\u503c\u77e9\u9635\u5b9e\u73b0\u5728\u6240\u6709\u7ef4\u5ea6\u4e0a\u4e00\u8d77\u63d2\u503c,\u6700\u5927\u9650\u5ea6\u7684\u4fdd\u7559\u4e86\u4fe1\u606f.\n\n## Install\n```bash\npip install glassInit\n```\n\n## Use\n```python\nfrom glassInit import glassInit_\n...\nlinear=torch.nn.Linear(512,2048,bias=False)\nglassInit_(linear.weight,inDim=...,outDim=0,gain=None,zeroMean=True)\n```\n\n\u5927\u591a\u6570\u65f6\u5019\u4e0d\u9700\u8981\u4f20\u5165\u5916\u90e8gain(\u9ed8\u8ba4\u4e3aNone)\u5982\u679c\u4f20\u5165\u5916\u90e8gain\u5219\u5185\u90e8gain\u4e0d\u751f\u6548.\n\n\u8f93\u5165\u5143\u7d20\u6570\u5c0f\u4e8e\u8f93\u51fa\u5143\u7d20\u6570\u4e14\u5173\u95ed\u7a00\u758f\u65f6\u5185\u90e8gain\u4e3a1. \u5426\u5219\u5185\u90e8gain\u4e3asqrt(\u8f93\u51fa\u5143\u7d20\u6570/\u8f93\u5165\u5143\u7d20\u6570)\n\n\u9700\u6839\u636e\u77e9\u9635\u5404\u7ef4\u5ea6\u7684\u4f5c\u7528\u586b\u5199inDim\u548coutDim,\u6700\u7ec8\u52a0\u5728\u4e00\u8d77\u7684\u8981\u586b\u5230inDim,\u8f93\u51fa\u65f6\u4ecd\u7136\u5206\u79bb\u7684\u8981\u586b\u5230outDim\n\n\u4e3e\u4f8b\u6765\u8bf4\u5377\u79ef\u5c42\u7684inChannel\u7ef4\u5ea6\u548ckernels\u7ef4\u5ea6\u8981\u586b\u5230inDim\u91cc,outChannel\u7ef4\u5ea6\u8981\u586b\u5230outDim\u91cc\n\n\u8f6c\u7f6e\u5377\u79ef\u8981\u6839\u636e\u8bbe\u5b9a\u53c2\u6570\u540e\u7684\u5177\u4f53\u884c\u4e3a\u51b3\u5b9akernels\u7ef4\u5ea6\u8981\u586b\u5230\u54ea\u91cc,\u53ef\u4ee5\u5148\u5199\u9053inDim\u4e2d\u5c1d\u8bd5\n\n\u5982\u679czeroMean\u4e3aFalse,\u8fd4\u56de\u77e9\u9635\u5c06\u6ca1\u6709\u5c0f\u4e8e\u96f6\u7684\u503c,\u5e76\u4e14\u662f\u63d2\u503c\u77e9\u9635.\u5426\u5219,\u8fd4\u56de\u77e9\u9635\u5c06\u5bf9\u63d2\u503c\u77e9\u9635\u9010\u5143\u7d20\u968f\u673a\u53d6\u53cd. \n\n\u5982\u679c\u8f93\u5165\u5143\u7d20\u6570\u5927\u4e8e\u8f93\u51fa\u5143\u7d20\u6570\u6216\u5173\u95ed\u7a00\u758f,\u77e9\u9635\u5b9e\u73b0\u7ebf\u6027\u63d2\u503c,\u5426\u5219\u662f\u63d20\u63d2\u503c.\u4e24\u79cd\u63d2\u503c\u5747\u4e3a\u5faa\u73af\u8fb9\u754c\u6761\u4ef6. \n\n\n## HomePage\n<https://github.com/PsycheHalo/glassInit/>\n",
"bugtrack_url": null,
"license": null,
"summary": "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. ",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/PsycheHalo/glassInit",
"Issues": "https://github.com/PsycheHalo/glassInit/issues"
},
"split_keywords": [
"glassinit",
" initialize",
" shortcut",
" pytorch",
" ai",
" neural",
" nn",
" connections",
" skip connections",
" res"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0af958a94d9dbc81560ea75bb916c7275ecf7397aee24bc369e55cf867c69ec4",
"md5": "d525a924e8d36e92f2c26e4bb28aa97a",
"sha256": "795b6d1183e8eac35267cd847d372ddbe3e5173bb295f5c8e255aba4759045ac"
},
"downloads": -1,
"filename": "glassinit-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d525a924e8d36e92f2c26e4bb28aa97a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11705,
"upload_time": "2025-08-06T13:26:50",
"upload_time_iso_8601": "2025-08-06T13:26:50.042279Z",
"url": "https://files.pythonhosted.org/packages/0a/f9/58a94d9dbc81560ea75bb916c7275ecf7397aee24bc369e55cf867c69ec4/glassinit-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8c559afba18ef33e97dc6ce010e9a65654512b30dd1b0dbf3cf9765eea1bac29",
"md5": "89a6344d69c4a7ec104ccc56fa14ff71",
"sha256": "136a1ce3a76852c476a8560a242c7cc1893c20df03d914e06df2d8b3c606aff1"
},
"downloads": -1,
"filename": "glassinit-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "89a6344d69c4a7ec104ccc56fa14ff71",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11008,
"upload_time": "2025-08-06T13:26:50",
"upload_time_iso_8601": "2025-08-06T13:26:50.992550Z",
"url": "https://files.pythonhosted.org/packages/8c/55/9afba18ef33e97dc6ce010e9a65654512b30dd1b0dbf3cf9765eea1bac29/glassinit-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-06 13:26:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PsycheHalo",
"github_project": "glassInit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "glassinit"
}