ganch 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ganch-0.0.1/.gitignore ADDED
@@ -0,0 +1,184 @@
1
+ ### Data ###
2
+ *.csv
3
+ *.dat
4
+ *.efx
5
+ *.gbr
6
+ *.key
7
+ *.pps
8
+ *.ppt
9
+ *.pptx
10
+ *.sdf
11
+ *.tax2010
12
+ *.vcf
13
+ *.xml
14
+
15
+ ### macOS ###
16
+ # General
17
+ .DS_Store
18
+ .AppleDouble
19
+ .LSOverride
20
+
21
+ # Icon must end with two \r
22
+ Icon
23
+
24
+
25
+ # Thumbnails
26
+ ._*
27
+
28
+ # Files that might appear in the root of a volume
29
+ .DocumentRevisions-V100
30
+ .fseventsd
31
+ .Spotlight-V100
32
+ .TemporaryItems
33
+ .Trashes
34
+ .VolumeIcon.icns
35
+ .com.apple.timemachine.donotpresent
36
+
37
+ ### macOS Patch ###
38
+ # iCloud generated files
39
+ *.icloud
40
+
41
+ ### OpenCV ###
42
+ #OpenCV for Mac and Linux
43
+ #build and release folders
44
+ */CMakeFiles
45
+ */CMakeCache.txt
46
+ */Makefile
47
+ */cmake_install.cmake
48
+
49
+ ### PyCharm ###
50
+ .idea/**/workspace.xml
51
+ .idea/**/tasks.xml
52
+ .idea/**/usage.statistics.xml
53
+ .idea/**/dictionaries
54
+ .idea/**/shelf
55
+ .idea/**/aws.xml
56
+ .idea/**/contentModel.xml
57
+ .idea/**/dataSources/
58
+ .idea/**/dataSources.ids
59
+ .idea/**/dataSources.local.xml
60
+ .idea/**/sqlDataSources.xml
61
+ .idea/**/dynamic.xml
62
+ .idea/**/uiDesigner.xml
63
+ .idea/**/dbnavigator.xml
64
+ .idea/**/gradle.xml
65
+ .idea/**/libraries
66
+ cmake-build-*/
67
+ .idea/**/mongoSettings.xml
68
+ *.iws
69
+ out/
70
+ .idea_modules/
71
+ atlassian-ide-plugin.xml
72
+ .idea/replstate.xml
73
+ .idea/sonarlint/
74
+ com_crashlytics_export_strings.xml
75
+ crashlytics.properties
76
+ crashlytics-build.properties
77
+ fabric.properties
78
+ .idea/httpRequests
79
+ .idea/caches/build_file_checksums.ser
80
+
81
+ ### PyCharm Patch ###
82
+ .idea/**/sonarlint/
83
+ .idea/**/sonarIssues.xml
84
+ .idea/**/markdown-navigator.xml
85
+ .idea/**/markdown-navigator-enh.xml
86
+ .idea/**/markdown-navigator/
87
+ .idea/$CACHE_FILE$
88
+ .idea/codestream.xml
89
+ .idea/**/azureSettings.xml
90
+
91
+ ### Python ###
92
+ __pycache__/
93
+ *.py[cod]
94
+ *$py.class
95
+ *.so
96
+ .Python
97
+ build/
98
+ develop-eggs/
99
+ dist/
100
+ downloads/
101
+ eggs/
102
+ .eggs/
103
+ lib/
104
+ lib64/
105
+ parts/
106
+ sdist/
107
+ var/
108
+ wheels/
109
+ share/python-wheels/
110
+ *.egg-info/
111
+ .installed.cfg
112
+ *.egg
113
+ MANIFEST
114
+ *.manifest
115
+ *.spec
116
+ pip-log.txt
117
+ pip-delete-this-directory.txt
118
+ htmlcov/
119
+ .tox/
120
+ .nox/
121
+ .coverage
122
+ .coverage.*
123
+ .cache
124
+ nosetests.xml
125
+ coverage.xml
126
+ *.cover
127
+ *.py,cover
128
+ .hypothesis/
129
+ .pytest_cache/
130
+ cover/
131
+ *.mo
132
+ *.pot
133
+ *.log
134
+ local_settings.py
135
+ db.sqlite3
136
+ db.sqlite3-journal
137
+ instance/
138
+ .webassets-cache
139
+ .scrapy
140
+ docs/_build/
141
+ .pybuilder/
142
+ target/
143
+ .ipynb_checkpoints
144
+ profile_default/
145
+ ipython_config.py
146
+ __pypackages__/
147
+ celerybeat-schedule
148
+ celerybeat.pid
149
+ *.sage.py
150
+ .env
151
+ .venv
152
+ env/
153
+ venv/
154
+ ENV/
155
+ env.bak/
156
+ venv.bak/
157
+ .spyderproject
158
+ .spyproject
159
+ .ropeproject
160
+ /site
161
+ .mypy_cache/
162
+ .dmypy.json
163
+ dmypy.json
164
+ .pyre/
165
+ .pytype/
166
+ cython_debug/
167
+ poetry.toml
168
+ .ruff_cache/
169
+ pyrightconfig.json
170
+
171
+ ### Project-specific additions ###
172
+ # PyCharm project folder (was previously excluded piece-by-piece above; this covers it fully)
173
+ .idea/
174
+ *.iml
175
+
176
+ # Datasets (too large for git — keep local)
177
+ data/
178
+
179
+ # YOLO / Ultralytics training outputs
180
+ runs/
181
+ weights/
182
+ *.pt
183
+ *.onnx
184
+ *.pth
ganch-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Azamat E. Zakirovich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ganch-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.5
2
+ Name: ganch
3
+ Version: 0.0.1
4
+ Summary: A multilayer perceptron library built from scratch with NumPy
5
+ Project-URL: Homepage, https://github.com/E-Zakirovich/ganch
6
+ Author: Azamat E. Zakirovich
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.9
10
+ Requires-Dist: numpy
11
+ Description-Content-Type: text/markdown
12
+
13
+ # ganch
14
+ With the help of this project I built a whole multilayer perceptron layer from scratch by using the numpy Python library. It supports forward and backpropagation, optimizations.
ganch-0.0.1/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # ganch
2
+ With the help of this project I built a whole multilayer perceptron layer from scratch by using the numpy Python library. It supports forward and backpropagation, optimizations.
@@ -0,0 +1,195 @@
1
+ <mxfile host="Electron">
2
+ <diagram name="Page-1" id="m6phiDB_jHeIBxxBi7_J">
3
+ <mxGraphModel dx="1295" dy="940" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="4681" pageHeight="3300" math="0" shadow="0">
4
+ <root>
5
+ <mxCell id="0" />
6
+ <mxCell id="1" parent="0" />
7
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-1" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="Ganch" vertex="1">
8
+ <mxGeometry height="60" width="120" x="115" y="212" as="geometry" />
9
+ </mxCell>
10
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-23" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-2" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-7">
11
+ <mxGeometry relative="1" as="geometry">
12
+ <Array as="points">
13
+ <mxPoint x="179" y="398.4" />
14
+ <mxPoint x="764" y="398.4" />
15
+ </Array>
16
+ </mxGeometry>
17
+ </mxCell>
18
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-2" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="&lt;div style=&quot;text-align: start;&quot;&gt;&lt;span style=&quot;text-align: center;&quot;&gt;losses&lt;/span&gt;&lt;/div&gt;" vertex="1">
19
+ <mxGeometry height="60" width="120" x="119" y="412" as="geometry" />
20
+ </mxCell>
21
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-67" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-5">
22
+ <mxGeometry relative="1" as="geometry" />
23
+ </mxCell>
24
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-3" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="model" vertex="1">
25
+ <mxGeometry height="60" width="120" x="664" y="430" as="geometry" />
26
+ </mxCell>
27
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-31" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.75;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-7">
28
+ <mxGeometry relative="1" as="geometry" />
29
+ </mxCell>
30
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-4" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="optimizers" vertex="1">
31
+ <mxGeometry height="60" width="120" x="925" y="368" as="geometry" />
32
+ </mxCell>
33
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-10" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-6">
34
+ <mxGeometry relative="1" as="geometry" />
35
+ </mxCell>
36
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-11" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-7">
37
+ <mxGeometry relative="1" as="geometry" />
38
+ </mxCell>
39
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-5" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="mlp.py" vertex="1">
40
+ <mxGeometry height="60" width="120" x="518" y="296" as="geometry" />
41
+ </mxCell>
42
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-6" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="__init__.py" vertex="1">
43
+ <mxGeometry height="60" width="120" x="298" y="296" as="geometry" />
44
+ </mxCell>
45
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-7" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="train.py" vertex="1">
46
+ <mxGeometry height="60" width="120" x="704" y="296" as="geometry" />
47
+ </mxCell>
48
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-8" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="configs.py" vertex="1">
49
+ <mxGeometry height="60" width="120" x="704" y="144" as="geometry" />
50
+ </mxCell>
51
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-22" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-2">
52
+ <mxGeometry relative="1" as="geometry" />
53
+ </mxCell>
54
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-14" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="__init__.py" vertex="1">
55
+ <mxGeometry height="60" width="120" x="68" y="502" as="geometry" />
56
+ </mxCell>
57
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-15" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="loss.py" vertex="1">
58
+ <mxGeometry height="60" width="120" x="226" y="502" as="geometry" />
59
+ </mxCell>
60
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-19" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-15">
61
+ <mxGeometry relative="1" as="geometry" />
62
+ </mxCell>
63
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-16" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="cross_entropy_loss.py" vertex="1">
64
+ <mxGeometry height="60" width="146" x="217" y="622" as="geometry" />
65
+ </mxCell>
66
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-17" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="mse.py" vertex="1">
67
+ <mxGeometry height="60" width="120" x="74" y="575" as="geometry" />
68
+ </mxCell>
69
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-18" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.408;entryY=0.939;entryDx=0;entryDy=0;entryPerimeter=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-15">
70
+ <mxGeometry relative="1" as="geometry" />
71
+ </mxCell>
72
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-21" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.977;entryY=0.491;entryDx=0;entryDy=0;entryPerimeter=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-14">
73
+ <mxGeometry relative="1" as="geometry" />
74
+ </mxCell>
75
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-55" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-25" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-54">
76
+ <mxGeometry relative="1" as="geometry" />
77
+ </mxCell>
78
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-25" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="layers.py" vertex="1">
79
+ <mxGeometry height="60" width="120" x="638" y="622" as="geometry" />
80
+ </mxCell>
81
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-29" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-26" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-3">
82
+ <mxGeometry relative="1" as="geometry" />
83
+ </mxCell>
84
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-26" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="__init__.py" vertex="1">
85
+ <mxGeometry height="60" width="120" x="521" y="522" as="geometry" />
86
+ </mxCell>
87
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-49" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-48">
88
+ <mxGeometry relative="1" as="geometry" />
89
+ </mxCell>
90
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-32" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="optimizer.py" vertex="1">
91
+ <mxGeometry height="60" width="120" x="841" y="530" as="geometry" />
92
+ </mxCell>
93
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-44" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-35" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-32">
94
+ <mxGeometry relative="1" as="geometry">
95
+ <Array as="points">
96
+ <mxPoint x="1183.3" y="589" />
97
+ <mxPoint x="1183.3" y="545" />
98
+ </Array>
99
+ </mxGeometry>
100
+ </mxCell>
101
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-35" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="momentum.py" vertex="1">
102
+ <mxGeometry height="60" width="120" x="1023" y="559" as="geometry" />
103
+ </mxCell>
104
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-45" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-36" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-32">
105
+ <mxGeometry relative="1" as="geometry">
106
+ <Array as="points">
107
+ <mxPoint x="1183.3" y="652" />
108
+ <mxPoint x="1183.3" y="545" />
109
+ </Array>
110
+ </mxGeometry>
111
+ </mxCell>
112
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-36" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="nesterov.py" vertex="1">
113
+ <mxGeometry height="60" width="120" x="1023" y="622" as="geometry" />
114
+ </mxCell>
115
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-46" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-37" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-32">
116
+ <mxGeometry relative="1" as="geometry">
117
+ <Array as="points">
118
+ <mxPoint x="1183.4" y="716" />
119
+ <mxPoint x="1183.4" y="545" />
120
+ </Array>
121
+ </mxGeometry>
122
+ </mxCell>
123
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-37" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="rmsprop.py" vertex="1">
124
+ <mxGeometry height="60" width="120" x="1023" y="686" as="geometry" />
125
+ </mxCell>
126
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-47" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-38" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-32">
127
+ <mxGeometry relative="1" as="geometry">
128
+ <Array as="points">
129
+ <mxPoint x="1183.4" y="779" />
130
+ <mxPoint x="1183.4" y="545" />
131
+ </Array>
132
+ </mxGeometry>
133
+ </mxCell>
134
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-38" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="adam.py" vertex="1">
135
+ <mxGeometry height="60" width="120" x="1023" y="749" as="geometry" />
136
+ </mxCell>
137
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-50" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-4">
138
+ <mxGeometry relative="1" as="geometry" />
139
+ </mxCell>
140
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-48" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="__init__.py" vertex="1">
141
+ <mxGeometry height="60" width="120" x="1009" y="451" as="geometry" />
142
+ </mxCell>
143
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-51" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.992;entryY=0.385;entryDx=0;entryDy=0;entryPerimeter=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-1">
144
+ <mxGeometry relative="1" as="geometry" />
145
+ </mxCell>
146
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-60" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-52" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-25">
147
+ <mxGeometry relative="1" as="geometry">
148
+ <Array as="points">
149
+ <mxPoint x="531" y="802.1" />
150
+ <mxPoint x="778" y="802.1" />
151
+ <mxPoint x="778" y="652" />
152
+ </Array>
153
+ </mxGeometry>
154
+ </mxCell>
155
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-52" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="activations.py" vertex="1">
156
+ <mxGeometry height="60" width="120" x="471" y="729" as="geometry" />
157
+ </mxCell>
158
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-65" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-53" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-25">
159
+ <mxGeometry relative="1" as="geometry" />
160
+ </mxCell>
161
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-53" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="initializers.py" vertex="1">
162
+ <mxGeometry height="60" width="120" x="604" y="729" as="geometry" />
163
+ </mxCell>
164
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-54" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="model.py" vertex="1">
165
+ <mxGeometry height="60" width="120" x="473" y="642" as="geometry" />
166
+ </mxCell>
167
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-59" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-54" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.46;entryY=0.971;entryDx=0;entryDy=0;entryPerimeter=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-26">
168
+ <mxGeometry relative="1" as="geometry" />
169
+ </mxCell>
170
+ <mxCell id="MjUuoaEe4OgFYVhQ-0-U-1" edge="1" parent="1" source="dVGu2_0iNIgdl1JQTMkO-61" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;" target="dVGu2_0iNIgdl1JQTMkO-5">
171
+ <mxGeometry relative="1" as="geometry" />
172
+ </mxCell>
173
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-61" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="data.py" vertex="1">
174
+ <mxGeometry height="60" width="120" x="453" y="194" as="geometry" />
175
+ </mxCell>
176
+ <mxCell id="dVGu2_0iNIgdl1JQTMkO-64" parent="1" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" value="&lt;h1 style=&quot;margin-top: 0px;&quot;&gt;Configs file explanation&lt;/h1&gt;&lt;p&gt;This file is connected almost all files, if I draw an arrow for each, the design looks like a ugly, and i do not want an ugly arch style. Sorry guys :|&lt;/p&gt;" vertex="1">
177
+ <mxGeometry height="120" width="415" x="843" y="144" as="geometry" />
178
+ </mxCell>
179
+ <mxCell id="MjUuoaEe4OgFYVhQ-0-U-3" edge="1" parent="1" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;defaultLabelBackgroundColor=page;labelPadding=0 4;">
180
+ <mxGeometry relative="1" as="geometry">
181
+ <Array as="points">
182
+ <mxPoint x="1183.9" y="843" />
183
+ <mxPoint x="1183.9" y="545" />
184
+ </Array>
185
+ <mxPoint x="1144.0000000000002" y="843" as="sourcePoint" />
186
+ <mxPoint x="962" y="545" as="targetPoint" />
187
+ </mxGeometry>
188
+ </mxCell>
189
+ <mxCell id="MjUuoaEe4OgFYVhQ-0-U-2" parent="1" style="rounded=0;whiteSpace=wrap;html=1;" value="sgd.py" vertex="1">
190
+ <mxGeometry height="60" width="120" x="1023" y="813" as="geometry" />
191
+ </mxCell>
192
+ </root>
193
+ </mxGraphModel>
194
+ </diagram>
195
+ </mxfile>
Binary file
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ganch"
7
+ version = "0.0.1"
8
+ description = "A multilayer perceptron library built from scratch with NumPy"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "Azamat E. Zakirovich" }]
13
+ dependencies = ["numpy"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/E-Zakirovich/ganch"
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,61 @@
1
+ """
2
+ activations.py
3
+ ~~~~~~~~~~~~~~
4
+
5
+ Inside of this file I am going to write ReLU, Sigmoid, Softmax
6
+ activation functions and their gradient methods for each. Also,
7
+ I will use OOP for whole file and NumPy package.
8
+ """
9
+
10
+ import numpy as np
11
+
12
+ class Activations:
13
+
14
+ """
15
+ Sigmoid activation function. Mathematical formula is f(Z) = 1 / (1 + e ^ (-Z))
16
+ and grdient or df(Z) / dZ = f(Z) x (1 - f(Z)). Basically, sigmoid is used in
17
+ output layers for classification projects
18
+ """
19
+ def sigmoid(self, Z : np.ndarray) -> np.ndarray:
20
+ result : np.ndarray = 1 / (1 + np.exp(-Z))
21
+ return result
22
+
23
+ def sigmoid_grad(self, A : np.ndarray) -> np.ndarray:
24
+ gradient : np.ndarray = A * (1 - A)
25
+ return gradient
26
+
27
+ """
28
+ ReLU activation function. Mathematical formula for ReLU is f(Z) = Max(Z).
29
+ and gradient for ReLU is f'(Z) = 1 if f(Z) > 0 else 0. Basically, ReLU
30
+ activation function is used inside of hidden layers for any kind of pro-
31
+ jects.
32
+ """
33
+ def relu(self, Z : np.ndarray) -> np.ndarray:
34
+ result : np.ndarray = np.maximum(0, Z)
35
+ return result
36
+
37
+ def relu_grad(self, A : np.ndarray) -> np.ndarray:
38
+ gradient : np.ndarray = (A > 0).astype(float)
39
+ return gradient
40
+
41
+ """
42
+ Softmax activation functions. mathematical formula for Softmax
43
+ """
44
+ def softmax(self, Z : np.ndarray) -> np.ndarray:
45
+ exp_Z : np.ndarray = np.exp(Z - np.max(Z, axis=1, keepdims=True))
46
+ result : np.ndarray = exp_Z / np.sum(exp_Z, axis=1, keepdims=True)
47
+ return result
48
+
49
+ def softmax_grad(self, A : np.ndarray, dA: np.ndarray) -> np.ndarray:
50
+ sum_term : np.ndarray = np.sum(dA * A, axis=1, keepdims=True)
51
+ gradient : np.ndarray = A * (dA - sum_term)
52
+ return gradient
53
+
54
+ """
55
+ Linear activation function is used is regression problem
56
+ """
57
+ def linear(self, Z: np.ndarray) -> np.ndarray:
58
+ return Z
59
+
60
+ def linear_grad(self, A: np.ndarray) -> np.ndarray:
61
+ return np.ones_like(A)
@@ -0,0 +1,20 @@
1
+ """
2
+ initializer.py
3
+ ~~~~~~~~~~~~~~
4
+
5
+ with a help of this file, I can create costum weight for initialization.
6
+ It is smth like clever way to train, with help of the method I can reach
7
+ faster 0 loss
8
+ """
9
+
10
+ import numpy as np
11
+
12
+ class Initializers:
13
+
14
+ def xavier(self, n_inputs: int, n_units: int) -> np.ndarray:
15
+ std = np.sqrt(2 / (n_inputs + n_units))
16
+ return np.random.randn(n_inputs, n_units) * std
17
+
18
+ def he(self, n_inputs: int, n_units: int) -> np.ndarray:
19
+ std = np.sqrt(2 / n_inputs)
20
+ return np.random.randn(n_inputs, n_units) * std
@@ -0,0 +1,43 @@
1
+ """
2
+ layers.py
3
+ ~~~~~~~~~
4
+
5
+ with a help of this file, i will store each neurons, their activation functions.
6
+ This file is core of the whole project.
7
+ """
8
+
9
+ import numpy as np
10
+ from .activations import Activations
11
+ from .initializers import Initializers
12
+
13
+ class Layer:
14
+
15
+ def __init__(self, number_of_inputs : np.int_, number_of_outputs : np.int_, function : np.str_):
16
+ self.number_of_inputs : np.int_ = number_of_inputs # number of intputs for the each neuron
17
+ self.number_of_outputs : np.int_ = number_of_outputs # number of outputs for each neuron
18
+ activations = Activations() # call activation functions from activation functions stored file
19
+ self.function = function # key word for importing activation fucntions
20
+ self.activation_function = getattr(activations, self.function) # calling the activation function here
21
+ self.activation_function_derivative = getattr(activations, f"{self.function}_grad") # calling the activation functions grad methods
22
+ self.weights= Initializers().he(number_of_inputs, number_of_outputs) if self.function == "relu" else Initializers().xavier(number_of_inputs, number_of_outputs) # initialize weights based on the type of activation functions and number of inputs and outputs
23
+ self.bias = np.zeros((1, number_of_outputs)) # initialize biases as 0
24
+
25
+ # with a help of forward prop, i can reach untill output layer, the I can calculate the loss. And then, I can interact with backward
26
+ def forward(self, X : np.ndarray) -> np.ndarray:
27
+ self.X = X
28
+ Z : np.ndarray = self.X @ self.weights + self.bias
29
+ result : np.ndarray = self.activation_function(Z)
30
+ self.A = result
31
+ return result
32
+
33
+ def backward(self, grad: np.ndarray, is_output: bool = False) -> np.ndarray:
34
+ B = self.X.shape[0]
35
+ if is_output:
36
+ dZ = grad # output layer + matching loss: the loss already gives dZ
37
+ elif self.function == "softmax":
38
+ dZ = self.activation_function_derivative(self.A, grad)
39
+ else:
40
+ dZ = grad * self.activation_function_derivative(self.A)
41
+ self.dW = self.X.T @ dZ / B
42
+ self.db = dZ.sum(axis=0, keepdims=True) / B
43
+ return dZ @ self.weights.T
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes