flexibot 0.0.0__py3-none-any.whl

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.
flexibot/__init__.py ADDED
@@ -0,0 +1,109 @@
1
+ import numpy as np
2
+ import random as rad
3
+
4
+ class network():
5
+ def __init__(self, isizes, wsizes, bsizes):
6
+
7
+ # ~ initiate inputs ~ #
8
+ self.i1 = np.random.uniform(-0.1, 0.1, size=isizes.__getitem__(0))
9
+ self.i2 = np.random.uniform(-0.1, 0.1, size=isizes.__getitem__(1))
10
+ self.i3 = np.random.uniform(-0.1, 0.1, size=isizes.__getitem__(2))
11
+ self.i4 = np.random.uniform(-0.1, 0.1, size=isizes.__getitem__(3))
12
+
13
+ # ~ initiate parameters ~ #
14
+ self.w1 = np.random.uniform(-0.1, 0.1, size=wsizes.__getitem__(0))
15
+ self.w2 = np.random.uniform(-0.1, 0.1, size=wsizes.__getitem__(1))
16
+ self.w3 = np.random.uniform(-0.1, 0.1, size=wsizes.__getitem__(2))
17
+ self.w4 = np.random.uniform(-0.1, 0.1, size=wsizes.__getitem__(3))
18
+
19
+ self.b1 = np.random.uniform(-0.1, 0.1, size=bsizes.__getitem__(0))
20
+ self.b2 = np.random.uniform(-0.1, 0.1, size=bsizes.__getitem__(1))
21
+ self.b3 = np.random.uniform(-0.1, 0.1, size=bsizes.__getitem__(2))
22
+ self.b4 = np.random.uniform(-0.1, 0.1, size=bsizes.__getitem__(3))
23
+
24
+ def ReLU(self, activate):
25
+ if activate == True:
26
+ self.enable = True
27
+ else:
28
+ self.enable = False
29
+
30
+ def MatrixMultiplication(self, inchange):
31
+ """
32
+ input: numpy array
33
+ """
34
+
35
+ self.p1 = self.i1 @ self.w1 + self.b1
36
+ if self.enable == True:
37
+ self.p1 = np.maximum(0, self.p1)
38
+ self.i2 += inchange ** 2 / rad.uniform(1, 2)
39
+ self.p1 = np.resize(self.p1, self.i2.shape)
40
+ self.i2 += self.p1
41
+ self.i2 = np.clip(self.i2, -1.0, 1.0)
42
+
43
+
44
+
45
+ self.p2 = self.i2 @ self.w2 + self.b2
46
+ if self.enable == True:
47
+ self.p2 = np.maximum(0, self.p2)
48
+ self.i3 += inchange ** 2 / rad.uniform(1, 2)
49
+ self.p2 = np.resize(self.p2, self.i3.shape)
50
+ self.i3 += self.p2
51
+ self.i3 = np.clip(self.i3, -1.0, 1.0)
52
+
53
+
54
+
55
+ self.p3 = self.i3 @ self.w3 + self.b3
56
+ if self.enable == True:
57
+ self.p3 = np.maximum(0, self.p3)
58
+ self.i4 += inchange ** 2 / rad.uniform(1, 2)
59
+ self.p3 = np.resize(self.p3, self.i4.shape)
60
+ self.i4 += self.p3
61
+ self.i4 = np.clip(self.i4, -1.0, 1.0)
62
+
63
+
64
+
65
+ self.p4 = self.i4 @ self.w4 + self.b4
66
+ if self.enable == True:
67
+ self.p4 = np.maximum(0, self.p4)
68
+ self.i1 += inchange ** 2 / rad.uniform(1, 2)
69
+ self.p4 = np.resize(self.p4, self.i1.shape)
70
+ self.i1 += self.p4
71
+ self.i1 = np.clip(self.i1, -1.0, 1.0)
72
+
73
+
74
+ return self.p1, self.p2, self.p3, self.p4, self.i1, self.i2, self.i3, self.i4
75
+ def Smoothen(self, _inchange_):
76
+ self.MatrixMultiplication(_inchange_)
77
+
78
+ return np.ravel(self.p4)
79
+ def MSE(self, ref):
80
+
81
+ self.error = self.p4 - ref
82
+
83
+ MSE = np.power(self.error, 2)
84
+
85
+
86
+ self.MSE_loss = np.mean(MSE)
87
+
88
+ return self.MSE_loss, self.error
89
+
90
+ def Optim(self, lr):
91
+ grad4 = self.i4.T @ self.error
92
+ grad3 = self.i3.T @ self.error
93
+ grad2 = self.i2.T @ self.error
94
+ grad1 = self.i1.T @ self.error
95
+
96
+ # 2. MAGIC FIX: Force the gradients to match the exact shape
97
+ # of their respective weights before subtracting!
98
+ self.w4 -= lr * np.resize(grad4, self.w4.shape)
99
+ self.w3 -= lr * np.resize(grad3, self.w3.shape)
100
+ self.w2 -= lr * np.resize(grad2, self.w2.shape)
101
+ self.w1 -= lr * np.resize(grad1, self.w1.shape)
102
+
103
+ # 3. Clean bias updates (using resize so they always match the bias shape!)
104
+ self.b4 -= lr * np.resize(np.mean(self.error), self.b4.shape)
105
+ self.b3 -= lr * np.mean(self.error) # If these are always flat, they are fine
106
+ self.b2 -= lr * np.mean(self.error)
107
+ self.b1 -= lr * np.mean(self.error)
108
+
109
+ return self.w1, self.w2, self.w3, self.w4, self.b1, self.b2, self.b3, self.b4
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: flexibot
3
+ Version: 0.0.0
4
+ License-File: LICENSE
5
+ Dynamic: license-file
@@ -0,0 +1,6 @@
1
+ flexibot/__init__.py,sha256=VVERMJwg3w0HxcAl0zHhhSBWjDlO2SpcNJFWFpI9sSc,3982
2
+ flexibot-0.0.0.dist-info/licenses/LICENSE,sha256=xQS0sSLen-sCoy9R70cLPVJwh7lgyDb4EY3Ao3tFkyc,1093
3
+ flexibot-0.0.0.dist-info/METADATA,sha256=kmdDrDQXF-acm_V2NKujiQFM11LFgaPXk_5cA1HEPnk,101
4
+ flexibot-0.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
5
+ flexibot-0.0.0.dist-info/top_level.txt,sha256=s6CZ0wEqrCeuh-Jia4TAeHtThzFtcn5N-JL5trl1t28,9
6
+ flexibot-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,20 @@
1
+ MIT License
2
+ Copyright (c) 2026 Luke William Warren
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ flexibot