zenter-networks 0.1.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.
@@ -0,0 +1,26 @@
1
+ """
2
+ Zenter Networks
3
+ A Python neural network and evolution library.
4
+ """
5
+
6
+ __version__ = "0.1.0"
7
+ __author__ = "Luke Porteous"
8
+
9
+ print(r"""
10
+ ███████╗███████╗███╗ ██╗████████╗███████╗██████╗
11
+ ╚══███╔╝██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔══██╗
12
+ ███╔╝ █████╗ ██╔██╗ ██║ ██║ █████╗ ██████╔╝
13
+ ███╔╝ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗
14
+ ███████╗███████╗██║ ╚████║ ██║ ███████╗██║ ██║
15
+ ╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
16
+
17
+ NETWORKS
18
+ • NEURAL COMPUTING LIBRARY •
19
+ ------------------------------------
20
+ ZENTER NETWORKS v0.1.0
21
+ Initialising neural systems...
22
+ """)
23
+
24
+ from .get_from_data_network import run_network
25
+ from .save_neuro_networks import create_neuro_networks
26
+ from .fitness_scores import new_gen
@@ -0,0 +1,150 @@
1
+
2
+ import os
3
+ import sys
4
+ import time
5
+ import math
6
+
7
+ def bear():
8
+ def animate_bear(duration=10):
9
+
10
+ bear = [
11
+ " .-##############-.",
12
+ " .-############### ##############-.",
13
+ " ########### ###########",
14
+ " ### #### ### ####",
15
+ " ###### ##",
16
+ " ##### ###",
17
+ " ### ####",
18
+ " ## #####",
19
+ " ### ###",
20
+ " ### ##",
21
+ " ### ##",
22
+ " ### ### #### ##",
23
+ " ## ### #### #### ##",
24
+ " ##### #### ###",
25
+ " ######## ####",
26
+ " ### ##### ####",
27
+ " ### ####### #######",
28
+ " #### ## ######",
29
+ " ##### ### ####",
30
+ " ##### ##",
31
+ " ### ##",
32
+ " ## ####",
33
+ " ## #############",
34
+ " ## ########",
35
+ " ## #####",
36
+ " ### ## ##",
37
+ " #### ###",
38
+ " ####### ## #######",
39
+ " #### #### ########",
40
+ " #### ########### ###",
41
+ " ##### ########### ##",
42
+ " ########### ## ####",
43
+ " ######## ###############",
44
+ " #########",
45
+ ]
46
+
47
+ os.system("")
48
+
49
+ RESET = "\033[0m"
50
+ BLACK = "\033[38;2;30;30;30m"
51
+
52
+ width = max(len(line) for line in bear)
53
+ height = len(bear)
54
+
55
+ start = time.time()
56
+ frame = 0
57
+
58
+ sys.stdout.write("\033[?25l")
59
+
60
+ try:
61
+ while time.time() - start < duration:
62
+
63
+ t = frame / 30
64
+
65
+ # Main dance cycle
66
+ cycle = t * 2 * math.pi * 0.85
67
+
68
+ hip = math.sin(cycle)
69
+ shoulder = math.sin(cycle + math.pi * 0.65)
70
+
71
+ # Squashing and bouncing
72
+ bounce = abs(math.sin(cycle * 2)) * 1.5
73
+ squash = abs(math.sin(cycle)) * 0.7
74
+
75
+ canvas = [
76
+ [" "] * (width + 16)
77
+ for _ in range(height + 5)
78
+ ]
79
+
80
+ for y, line in enumerate(bear):
81
+
82
+ for x, char in enumerate(line):
83
+
84
+ if char == " ":
85
+ continue
86
+
87
+ # Movement spreads gradually from head to hips
88
+ if y < 10:
89
+ movement = shoulder * 0.35
90
+ elif y < 19:
91
+ movement = shoulder * 0.5 + hip * 0.5
92
+ else:
93
+ movement = hip * 2.5
94
+
95
+ # Body bending
96
+ movement += math.sin(cycle) * max(0, y - 12) * 0.035
97
+
98
+ new_x = round(x + movement)
99
+
100
+ # Legs move slightly with the dance
101
+ new_y = y
102
+
103
+ if y >= 27:
104
+ new_x += round(
105
+ math.sin(cycle + (0 if x < width / 2 else math.pi))
106
+ * 0.8
107
+ )
108
+
109
+ # Vertical body movement
110
+ if y >= 15:
111
+ new_y = round(y + squash - bounce * 0.5)
112
+
113
+ new_y = max(0, min(height + 3, new_y))
114
+ new_x = max(0, min(width + 15, new_x))
115
+
116
+ canvas[new_y][new_x] = char
117
+
118
+ # Draw frame
119
+ sys.stdout.write("\033[H\033[2J")
120
+
121
+ for row in canvas:
122
+ sys.stdout.write(
123
+ BLACK + "".join(row).rstrip() + RESET + "\n"
124
+ )
125
+
126
+ # Animated dance caption
127
+ captions = [
128
+ "WIGGLE",
129
+ "WIGGLE",
130
+ "WIGGLE",
131
+ "WIGGLE",
132
+ ]
133
+
134
+ caption = captions[frame % len(captions)]
135
+
136
+ sys.stdout.write(
137
+ "\n <3 " + caption + " <3\n"
138
+ )
139
+
140
+ sys.stdout.flush()
141
+
142
+ time.sleep(1 / 30)
143
+ frame += 1
144
+
145
+ finally:
146
+ sys.stdout.write("\033[?25h" + RESET + "\n")
147
+ sys.stdout.flush()
148
+
149
+ while True:
150
+ animate_bear()
@@ -0,0 +1,52 @@
1
+ import random
2
+ import json
3
+
4
+ def new_gen(fitness_scores, population_size, layers, mutation_chance, mutation_strength):
5
+ global current_gen_data
6
+ with open("data.json", "r") as json_file:
7
+ neuro_network_data = json.load(json_file)
8
+
9
+ current_gen_data = neuro_network_data
10
+
11
+ best_paired = list(zip(current_gen_data["network"], fitness_scores))
12
+ best_paired.sort(key=lambda pair: pair[1], reverse=True)
13
+ best_paired = best_paired[:2]
14
+
15
+ parent_a = current_gen_data["network"].index(best_paired[0][0])
16
+ parent_b = current_gen_data["network"].index(best_paired[1][0])
17
+
18
+ print("Parent A:", parent_a)
19
+ print("Parent B:", parent_b)
20
+
21
+ new_gen_data_base = {
22
+ "network": [],
23
+ "data": []
24
+ }
25
+
26
+ for r in range(population_size):
27
+ new_gen = {}
28
+ for f in range(len(layers)):
29
+ layer_number = f
30
+
31
+ new_gen[f"layer_{layer_number}_weights"] = []
32
+ new_gen[f"layer_{layer_number}_biases"] = []
33
+
34
+ for n in range(len(layers)):
35
+ for q in range(layers[f"{n+1}"]["neurons"]):
36
+ parent = random.choice([parent_a, parent_b])
37
+ child_weights = current_gen_data["data"][parent][f"layer_{n}_weights"][q].copy()
38
+ child_biases = current_gen_data["data"][parent][f"layer_{n}_biases"][q]
39
+ for i in range(len(child_weights)):
40
+ if random.random() < mutation_chance:
41
+ child_weights[i] += random.uniform((-mutation_strength/2), (mutation_strength/2))
42
+ if random.random() < mutation_chance:
43
+ child_biases += random.uniform((-mutation_strength/2), (mutation_strength/2))
44
+ new_gen[f"layer_{n}_weights"].append(child_weights)
45
+ new_gen[f"layer_{n}_biases"].append(child_biases)
46
+
47
+ new_gen_data_base["network"].append("network" + str(r))
48
+ new_gen_data_base["data"].append(new_gen)
49
+
50
+ with open("data.json", "w") as json_file:
51
+ json.dump(new_gen_data_base, json_file)
52
+ return True
@@ -0,0 +1,40 @@
1
+ import json
2
+
3
+ def run_network(inputs, network_index):
4
+
5
+ with open("data.json", "r") as json_file:
6
+ global neuro_network
7
+ neuro_network = json.load(json_file)
8
+
9
+ network = neuro_network["data"][network_index]
10
+
11
+ ### neuron fuction
12
+ def neuron(inputs, weights, bias):
13
+ output = 0
14
+
15
+ for s in range(len(inputs)):
16
+ output += inputs[s] * weights[s]
17
+
18
+ output += bias
19
+ # this is called a activation function called ReLU(Rectified Linear Unit)
20
+ if output <= 0:
21
+ output = 0
22
+ return output
23
+ ### neuron fuction
24
+
25
+ layer_inputs = inputs
26
+
27
+ for n in range(len(network)//2):
28
+
29
+ weights = network[f"layer_{n}_weights"]
30
+ biases = network[f"layer_{n}_biases"]
31
+
32
+ layer_outputs = []
33
+
34
+ for network_index in range(len(weights)):
35
+
36
+ layer_outputs.append(neuron(inputs= layer_inputs, weights= weights[network_index], bias= biases[network_index]))
37
+
38
+ layer_inputs = layer_outputs
39
+ OUTPUT = layer_outputs
40
+ return OUTPUT
@@ -0,0 +1,29 @@
1
+ import json
2
+ import random
3
+
4
+ def create_neuro_networks(networks, layers):
5
+
6
+ neuro_network_data_base = {
7
+ "network": [],
8
+ "data": []
9
+ }
10
+
11
+ for r in range(networks):
12
+ neuro_network = {}
13
+ for f in range(len(layers)):
14
+ layer_number = f
15
+
16
+ neuro_network[f"layer_{layer_number}_weights"] = []
17
+ neuro_network[f"layer_{layer_number}_biases"] = []
18
+
19
+ for n in range(len(layers)):
20
+ for q in range(layers[f"{n+1}"]["neurons"]):
21
+ neuro_network[f"layer_{n}_weights"].append([random.uniform(-1, 1) for u in range(layers[f"{n+1}"]["inputs"])])
22
+ neuro_network[f"layer_{n}_biases"].append(random.uniform(-1, 1))
23
+
24
+ neuro_network_data_base["network"].append("network" + str(r))
25
+ neuro_network_data_base["data"].append(neuro_network)
26
+
27
+ with open("data.json", "w") as json_file:
28
+ json.dump(neuro_network_data_base, json_file)
29
+ return True
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: zenter-networks
3
+ Version: 0.1.0
4
+ Summary: A Python neural network and evolution library
5
+ Author: luke porteous, zenter
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: license-file
11
+
12
+
13
+ # Zenter Networks
14
+
15
+ A Python library for creating, breeding and running customisable neural networks.
16
+
17
+ ## Features
18
+
19
+ - Neural network creation
20
+ - Feed-forward neural networks
21
+ - Customisable network architectures
22
+ - Random weight and bias generation
23
+ - Multiple neural network generation
24
+ - Breeding and evolving neuro networks
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install zenter-networks
30
+ ```
31
+
32
+ ## Basic Usage
33
+
34
+ ```python
35
+ import zenter_networks
36
+
37
+ layers = {
38
+ "1": {"inputs": 3, "neurons": 3},
39
+ "2": {"inputs": 3, "neurons": 4},
40
+ "3": {"inputs": 4, "neurons": 2}
41
+ }
42
+
43
+ generated = zenter_networks.create_neuro_networks(
44
+ networks=2,
45
+ layers=layers
46
+ )
47
+
48
+ inputs = [1, 2, 3]
49
+
50
+ outputs = zenter_networks.run_network(
51
+ inputs=inputs,
52
+ network_index=0
53
+ )
54
+
55
+ print(outputs)
56
+ ```
57
+
58
+ ## Requirements
59
+
60
+ - Python 3.10 or newer
61
+ - json pip install
62
+ - random pip install
63
+
64
+ ## Developer
65
+
66
+ Created by Luke Porteous.
67
+
68
+ ## Licence
69
+
70
+ MIT
@@ -0,0 +1,11 @@
1
+ zenter_networks/__init__.py,sha256=UxmkRwH45S_1B2rJMGLx1O7RHpY8Q9GlNpwlCB7A_po,1294
2
+ zenter_networks/bear.py,sha256=2k5aDncoJS76rSvvcRLpU2HZ81-8UJsM2jS7os9n7_o,5813
3
+ zenter_networks/fitness_scores.py,sha256=ro7T7YerT9Ffhmqq-45PPstkkp-pVQzT4y39CfHga_0,2092
4
+ zenter_networks/get_from_data_network.py,sha256=62lRFJ5UN20yXOmiCNhXqW2vDVZ5Oa_Rg2IU17HlEzo,1075
5
+ zenter_networks/save_neuro_networks.py,sha256=XYxVZdxAwpsfjwtKgTRE2xlPE-wawOMkzzmhfr0l728,987
6
+ zenter_networks-0.1.0.dist-info/licenses/LICENSE,sha256=7tuY85VNedfIgf7lPtyvOfVIb8gFt_pElrdRE9_Dd4A,830
7
+ zenter_networks-0.1.0.dist-info/METADATA,sha256=qdVynIzTVBSBkd8YH6-evNP6RwrYdZU31Dcu10Wphiw,1252
8
+ zenter_networks-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ zenter_networks-0.1.0.dist-info/entry_points.txt,sha256=KEwk-eZQLM-DH-Gly_t85lcD72Kg9dJIrCNn14YAcEw,51
10
+ zenter_networks-0.1.0.dist-info/top_level.txt,sha256=emok0RURyGaom_BvXCAPN_tqy_gPRBXdRzyL3Yvq1qs,16
11
+ zenter_networks-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bear = zenter_networks.bear:bear
@@ -0,0 +1,18 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2026 Luke Porteous
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -0,0 +1 @@
1
+ zenter_networks