pyai-new 0.1.0__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.
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyai-new
3
+ Version: 0.1.0
4
+ Summary: Мой собственный движок нейросетей на C++
5
+ Author: Глеб
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Requires-Python: >=3.6
9
+ Dynamic: author
10
+ Dynamic: classifier
11
+ Dynamic: requires-python
12
+ Dynamic: summary
@@ -0,0 +1,13 @@
1
+ # PyAI
2
+ Мой личный движок для обучения нейросетей, написанный на C++.
3
+
4
+ ## Установка
5
+ pip install .
6
+
7
+ ## Пример использования
8
+ from pyai import PyAI
9
+
10
+ ai = PyAI()
11
+ ai.create(2, 1, [16, 16])
12
+ ai.train([0.5, 0.5], [0.5])
13
+ print(ai.predict([0.5, 0.5]))
@@ -0,0 +1 @@
1
+ from .engine import PyAI
@@ -0,0 +1,52 @@
1
+ import ctypes
2
+ import os
3
+
4
+ class PyAI:
5
+ def __init__(self, lib_path=None):
6
+ if lib_path is None:
7
+ # Ищем DLL в той же папке, где лежит этот файл
8
+ lib_path = os.path.join(os.path.dirname(__file__), "pyai.dll")
9
+
10
+ self.lib = ctypes.CDLL(lib_path)
11
+
12
+ self.lib.create_network_from_config.argtypes = [
13
+ ctypes.c_int, ctypes.c_int, ctypes.POINTER(ctypes.c_int), ctypes.c_int, ctypes.c_float
14
+ ]
15
+ self.lib.create_network_from_config.restype = ctypes.c_int
16
+
17
+ self.lib.forward_pass.argtypes = [
18
+ ctypes.c_int, ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float)
19
+ ]
20
+
21
+ self.lib.train_step.argtypes = [
22
+ ctypes.c_int, ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float)
23
+ ]
24
+ self.lib.train_step.restype = ctypes.c_float
25
+
26
+ self.net_id = -1
27
+ self.input_size = 0
28
+ self.output_size = 0
29
+
30
+ def create(self, INPUT_NEURONS, OUTPUT_NEURONS, HIDDEN_LAYERS, learning_rate=0.05):
31
+ self.input_size = INPUT_NEURONS
32
+ self.output_size = OUTPUT_NEURONS
33
+
34
+ num_hidden = len(HIDDEN_LAYERS)
35
+ hidden_arr = (ctypes.c_int * num_hidden)(*HIDDEN_LAYERS)
36
+
37
+ self.net_id = self.lib.create_network_from_config(
38
+ self.input_size, self.output_size, hidden_arr, num_hidden, learning_rate
39
+ )
40
+ return self.net_id
41
+
42
+ def predict(self, inputs):
43
+ in_arr = (ctypes.c_float * self.input_size)(*inputs)
44
+ out_arr = (ctypes.c_float * self.output_size)()
45
+ self.lib.forward_pass(self.net_id, in_arr, out_arr)
46
+ return list(out_arr)
47
+
48
+ def train(self, inputs, targets):
49
+ in_arr = (ctypes.c_float * self.input_size)(*inputs)
50
+ target_arr = (ctypes.c_float * self.output_size)(*targets)
51
+ loss = self.lib.train_step(self.net_id, in_arr, target_arr)
52
+ return loss
Binary file
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyai-new
3
+ Version: 0.1.0
4
+ Summary: Мой собственный движок нейросетей на C++
5
+ Author: Глеб
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Requires-Python: >=3.6
9
+ Dynamic: author
10
+ Dynamic: classifier
11
+ Dynamic: requires-python
12
+ Dynamic: summary
@@ -0,0 +1,9 @@
1
+ README.md
2
+ setup.py
3
+ pyai/__init__.py
4
+ pyai/engine.py
5
+ pyai/pyai.dll
6
+ pyai_new.egg-info/PKG-INFO
7
+ pyai_new.egg-info/SOURCES.txt
8
+ pyai_new.egg-info/dependency_links.txt
9
+ pyai_new.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pyai
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,18 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="pyai-new", # <--- Вот тут имя нашего пакета!
5
+ version="0.1.0",
6
+ author="Глеб",
7
+ description="Мой собственный движок нейросетей на C++",
8
+ packages=find_packages(),
9
+ include_package_data=True,
10
+ package_data={
11
+ 'pyai': ['*.dll'], # Упаковываем DLL внутрь пакета
12
+ },
13
+ classifiers=[
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: Microsoft :: Windows",
16
+ ],
17
+ python_requires='>=3.6',
18
+ )