neuralplex 0.0.1__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.
- neuralplex/__init__.py +3 -0
- neuralplex/layer.py +14 -0
- neuralplex/network.py +36 -0
- neuralplex/perceptron.py +35 -0
- neuralplex-0.0.1.dist-info/METADATA +15 -0
- neuralplex-0.0.1.dist-info/RECORD +8 -0
- neuralplex-0.0.1.dist-info/WHEEL +4 -0
- neuralplex-0.0.1.dist-info/licenses/LICENSE +21 -0
neuralplex/__init__.py
ADDED
neuralplex/layer.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class Layer:
|
|
2
|
+
|
|
3
|
+
def __init__(self, perceptrons, deg):
|
|
4
|
+
self.perceptrons = perceptrons
|
|
5
|
+
self.deg = deg
|
|
6
|
+
|
|
7
|
+
if self.deg:
|
|
8
|
+
for perceptron in self.perceptrons:
|
|
9
|
+
perceptron.deg = self.deg
|
|
10
|
+
|
|
11
|
+
def connect(self, layer):
|
|
12
|
+
for p1 in self.perceptrons:
|
|
13
|
+
for p2 in layer.perceptrons:
|
|
14
|
+
p1.connect(p2)
|
neuralplex/network.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class Network:
|
|
2
|
+
|
|
3
|
+
def __init__(self, layers):
|
|
4
|
+
self.layers = layers;
|
|
5
|
+
self.input = layers[0];
|
|
6
|
+
self.output = layers[len(layers) - 1];
|
|
7
|
+
|
|
8
|
+
for i in range(0, len(layers) - 1):
|
|
9
|
+
l1 = layers[i]
|
|
10
|
+
l2 = layers[i + 1]
|
|
11
|
+
l1.connect(l2)
|
|
12
|
+
|
|
13
|
+
def epoch(self, inputs, outputs):
|
|
14
|
+
if len(self.input.perceptrons) != len(inputs):
|
|
15
|
+
raise Exception(f'The length of the training values, {len(inputs)}, is not equal to the number of input perceptrons: {len(self.input.perceptrons)}')
|
|
16
|
+
|
|
17
|
+
if len(self.output.perceptrons) != len(outputs):
|
|
18
|
+
raise Exception(f'The length of the training values, {len(outputs)}, is not equal to the number of output perceptrons: {len(self.output.perceptrons)}')
|
|
19
|
+
|
|
20
|
+
for i in range(0, len(inputs)):
|
|
21
|
+
self.input.perceptrons[i].activate(inputs[i])
|
|
22
|
+
|
|
23
|
+
for i in range(0, len(outputs)):
|
|
24
|
+
o = outputs[i]
|
|
25
|
+
p = self.output.perceptrons[i]
|
|
26
|
+
p.propagate(p.q-o)
|
|
27
|
+
|
|
28
|
+
def predict(self, inputs):
|
|
29
|
+
|
|
30
|
+
if len(self.input.perceptrons) != len(inputs):
|
|
31
|
+
raise Exception(f'The length of the training values, ${len(inputs)}, is not equal to the number of input perceptrons: {len(self.input.perceptrons)}')
|
|
32
|
+
|
|
33
|
+
for i in range(0, len(inputs)):
|
|
34
|
+
self.input.perceptrons[i].activate(inputs[i]);
|
|
35
|
+
|
|
36
|
+
return [perceptron.q for perceptron in self.output.perceptrons]
|
neuralplex/perceptron.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class Perceptron:
|
|
2
|
+
|
|
3
|
+
def __init__(self, coef, deg=1):
|
|
4
|
+
self.coef = coef
|
|
5
|
+
self.deg = deg
|
|
6
|
+
self.perceptronsRHS = []
|
|
7
|
+
self.perceptronsLHS = []
|
|
8
|
+
self.activations = []
|
|
9
|
+
self.propagations = []
|
|
10
|
+
self.q = 0
|
|
11
|
+
|
|
12
|
+
def connect(self, perceptron):
|
|
13
|
+
self.perceptronsRHS.append(perceptron);
|
|
14
|
+
perceptron.perceptronsLHS.append(self);
|
|
15
|
+
|
|
16
|
+
def activate(self, t):
|
|
17
|
+
self.activations.append(self.coef * t**self.deg)
|
|
18
|
+
if len(self.perceptronsLHS) == 0 or len(self.activations) == len(self.perceptronsLHS):
|
|
19
|
+
self.q = sum(self.activations)
|
|
20
|
+
for perceptron in self.perceptronsRHS:
|
|
21
|
+
perceptron.activate(self.q)
|
|
22
|
+
self.activations = []
|
|
23
|
+
|
|
24
|
+
def propagate(self, t):
|
|
25
|
+
self.propagations.append(t)
|
|
26
|
+
if len(self.perceptronsRHS) == 0 or len(self.propagations) == len(self.perceptronsRHS):
|
|
27
|
+
d = sum(self.propagations)
|
|
28
|
+
if d > 0:
|
|
29
|
+
self.coef = self.coef - 1e-5
|
|
30
|
+
else:
|
|
31
|
+
self.coef = self.coef + 1e-5
|
|
32
|
+
|
|
33
|
+
for perceptron in self.perceptronsLHS:
|
|
34
|
+
perceptron.propagate(d)
|
|
35
|
+
self.propagations = []
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: neuralplex
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Neuralplex.
|
|
5
|
+
Project-URL: Homepage, https://github.com/faranalytics/neuralplex
|
|
6
|
+
Project-URL: Issues, https://github.com/faranalytics/neuralplex/issues
|
|
7
|
+
Author-email: FAR Analytics & Research <adam@farar.net>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# neuralplex
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
neuralplex/__init__.py,sha256=BqLElFtqf8Auz6L8FhWddXZi-avE-eyaEQgCzrBcEEo,88
|
|
2
|
+
neuralplex/layer.py,sha256=jO6rjigxGpbfVgMzyZt6OY3O3JasuJxXExKPBQm48jw,368
|
|
3
|
+
neuralplex/network.py,sha256=mvrv-sj-0IlIg-bZWm_ePgBPrVZvPzcPCgLzhAcckRI,1428
|
|
4
|
+
neuralplex/perceptron.py,sha256=J3T5n6AbjpVrLM2LLFpjVOzVOVeJZMXs6kWQoNYVeCw,1204
|
|
5
|
+
neuralplex-0.0.1.dist-info/METADATA,sha256=iIG64JXfsxjDtQGGDQaLZJrrwt0fkheEt1eqARmI1oA,514
|
|
6
|
+
neuralplex-0.0.1.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
|
|
7
|
+
neuralplex-0.0.1.dist-info/licenses/LICENSE,sha256=C_XDFNZuiaBnTzrum_j7RmxlLLAby9rVu6vt1C9mwco,1081
|
|
8
|
+
neuralplex-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FAR Analytics & Research
|
|
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.
|