pyerualjetwork 1.2.8__tar.gz → 1.2.9__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,8 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyerualjetwork
3
+ Version: 1.2.9
4
+ Summary: Advanced python deep learning library. New Visualize parameter added ('y' or 'n') for TrainPlan and TestPLAN funcs. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
5
+ Author: Hasan Can Beydili
6
+ Author-email: tchasancan@gmail.com
7
+ Keywords: model evaluation,classifcation,pruning learning artficial neural networks
8
+ Provides-Extra: visualization
@@ -4,6 +4,8 @@ from colorama import Fore,Style
4
4
  from typing import List, Union
5
5
  import math
6
6
  from scipy.special import expit, softmax
7
+ import matplotlib.pyplot as plt
8
+ import seaborn as sns
7
9
 
8
10
  # BUILD -----
9
11
  def TrainPLAN(
@@ -15,7 +17,8 @@ def TrainPLAN(
15
17
  MembranThresholds: List[str],
16
18
  MembranPotentials: List[Union[int, float]],
17
19
  Normalizations: List[str],
18
- Activations: List[str]
20
+ Activations: List[str],
21
+ Visualize: str
19
22
  ) -> str:
20
23
 
21
24
  infoPLAN = """
@@ -31,12 +34,18 @@ def TrainPLAN(
31
34
  MembranPotentials (list[num]): List of MembranPotentials.
32
35
  Normalizations (List[str]): Whether normalization will be performed at indexed layers ("y" or "n").
33
36
  Activations (list[str]): List of activation functions.
37
+ Visualize (str): Visualize Training procces or not visualize ('y' or 'n')
34
38
 
35
39
  Returns:
36
40
  list([num]): (Weight matrices list, TrainPredictions list, TrainAcc).
37
41
  error handled ?: Process status ('e')
38
42
  """
39
43
 
44
+ if Visualize != 'y' and Visualize != 'n':
45
+ print(Fore.RED + "ERROR109: Visualize parameter must be 'y' or 'n'. TrainPLAN",infoPLAN)
46
+ return 'e'
47
+
48
+
40
49
  LastNeuron = Neurons[-1:][0]
41
50
  if LastNeuron != ClassCount:
42
51
  print(Fore.RED + "ERROR108: Last layer of neuron count must be equal class count. from: TrainPLAN",infoPLAN)
@@ -142,7 +151,7 @@ def TrainPLAN(
142
151
  Divides = SynapticDividing(ClassCount,W)
143
152
  TrainedWs = [1] * len(W)
144
153
  print(Fore.GREEN + "Train Started with 0 ERROR" + Style.RESET_ALL,)
145
- TrainPredictions = [1] * len(TrainLabels)
154
+ TrainPredictions = [None] * len(TrainLabels)
146
155
  true = 0
147
156
  StartTime = time.time()
148
157
  for index, inp in enumerate(TrainInputs):
@@ -192,6 +201,24 @@ def TrainPLAN(
192
201
  Acc = true / len(TrainLabels)
193
202
  TrainPredictions[index] = PredictedOutput
194
203
 
204
+ if Visualize == 'y':
205
+
206
+ TrainLabelsVisual = np.copy(TrainLabels)
207
+ TrainLabelsVisual = np.argmax(TrainLabelsVisual, axis=1)
208
+
209
+ plt.figure(figsize=(12, 6))
210
+ sns.kdeplot(TrainLabelsVisual, label='Real Outputs', shade=True)
211
+ sns.kdeplot(TrainPredictions, label='Predictions', shade=True)
212
+ plt.legend()
213
+ plt.xlabel('Class')
214
+ plt.ylabel('Data size')
215
+ plt.title('Predictions and Real Outputs for Training KDE Plot')
216
+ plt.show()
217
+
218
+ if index + 1 != len(TrainInputs):
219
+
220
+ plt.close('all')
221
+
195
222
  if index == 0:
196
223
  for i, w in enumerate(W):
197
224
  TrainedWs[i] = w
@@ -537,7 +564,8 @@ def TestPLAN(
537
564
  MembranThresholds, # list[str]: List of MEMBRAN THRESHOLDS for each layer.
538
565
  MembranPotentials, # list[num]: List of MEMBRAN POTENTIALS for each layer.
539
566
  Normalizations, # str: Whether normalization will be performed ("y" or "n").
540
- Activations, # str: Activation function list for the neural network.
567
+ Activations, # str: Activation function list for the neural network.
568
+ Visualize, # Visualize Testing procces or not visualize ('y' or 'n')
541
569
  W # list[list[num]]: Weight matrix of the neural network.
542
570
  ) -> tuple:
543
571
  infoTestModel = """
@@ -561,7 +589,7 @@ def TestPLAN(
561
589
  try:
562
590
  Wc = [0] * len(W)
563
591
  true = 0
564
- TestPredictions = [1] * len(TestLabels)
592
+ TestPredictions = [None] * len(TestLabels)
565
593
  for i, w in enumerate(W):
566
594
  Wc[i] = np.copy(w)
567
595
  print('\rCopying weights.....',i+1,'/',len(W),end = "")
@@ -596,6 +624,25 @@ def TestPLAN(
596
624
  true += 1
597
625
  Acc = true / len(TestLabels)
598
626
  TestPredictions[inpIndex] = PredictedOutput
627
+
628
+ if Visualize == 'y':
629
+
630
+ TestLabelsVisual = np.copy(TestLabels)
631
+ TestLabelsVisual = np.argmax(TestLabelsVisual, axis=1)
632
+
633
+ plt.figure(figsize=(12, 6))
634
+ sns.kdeplot(TestLabelsVisual, label='Real Outputs', shade=True)
635
+ sns.kdeplot(TestPredictions, label='Predictions', shade=True)
636
+ plt.legend()
637
+ plt.xlabel('Class')
638
+ plt.ylabel('Data size')
639
+ plt.title('Predictions and Real Outputs for Testing KDE Plot')
640
+ plt.show()
641
+
642
+ if inpIndex + 1 != len(TestInputs):
643
+
644
+ plt.close('all')
645
+
599
646
  UniEndTime = time.time()
600
647
 
601
648
  CalculatingEst = round((UniEndTime - UniStartTime) * (len(TestInputs) - inpIndex),3)
@@ -1045,4 +1092,4 @@ def GetPreds():
1045
1092
 
1046
1093
  def GetAcc():
1047
1094
 
1048
- return 2
1095
+ return 2
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyerualjetwork
3
+ Version: 1.2.9
4
+ Summary: Advanced python deep learning library. New Visualize parameter added ('y' or 'n') for TrainPlan and TestPLAN funcs. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
5
+ Author: Hasan Can Beydili
6
+ Author-email: tchasancan@gmail.com
7
+ Keywords: model evaluation,classifcation,pruning learning artficial neural networks
8
+ Provides-Extra: visualization
@@ -4,4 +4,5 @@ plan/plan.py
4
4
  pyerualjetwork.egg-info/PKG-INFO
5
5
  pyerualjetwork.egg-info/SOURCES.txt
6
6
  pyerualjetwork.egg-info/dependency_links.txt
7
+ pyerualjetwork.egg-info/requires.txt
7
8
  pyerualjetwork.egg-info/top_level.txt
@@ -0,0 +1,10 @@
1
+ numpy
2
+ scipy
3
+ time
4
+ math
5
+ colorama
6
+ typing
7
+
8
+ [visualization]
9
+ matplotlib
10
+ seaborn
@@ -0,0 +1,27 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ # Setting Up
4
+
5
+ setup(
6
+
7
+ name = "pyerualjetwork",
8
+ version = "1.2.9",
9
+ author = "Hasan Can Beydili",
10
+ author_email = "tchasancan@gmail.com",
11
+ description= "Advanced python deep learning library. New Visualize parameter added ('y' or 'n') for TrainPlan and TestPLAN funcs. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)",
12
+ packages = find_packages(),
13
+ keywords = ["model evaluation", "classifcation", 'pruning learning artficial neural networks'],
14
+ install_requires=[
15
+ 'numpy',
16
+ 'scipy',
17
+ 'time',
18
+ 'math',
19
+ 'colorama',
20
+ 'typing'
21
+ ],
22
+
23
+ extras_require={
24
+ 'visualization': ['matplotlib','seaborn']
25
+ }
26
+
27
+ )
@@ -1,7 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyerualjetwork
3
- Version: 1.2.8
4
- Summary: Advanced python deep learning library. 'ThresholdSigns' changed to 'MembranThresholds' and 'ThresholdValues' changed to 'MembranPotentials'. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
5
- Author: Hasan Can Beydili
6
- Author-email: tchasancan@gmail.com
7
- Keywords: model evaluation,classifcation,pruning learning artficial neural networks
@@ -1,7 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: pyerualjetwork
3
- Version: 1.2.8
4
- Summary: Advanced python deep learning library. 'ThresholdSigns' changed to 'MembranThresholds' and 'ThresholdValues' changed to 'MembranPotentials'. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)
5
- Author: Hasan Can Beydili
6
- Author-email: tchasancan@gmail.com
7
- Keywords: model evaluation,classifcation,pruning learning artficial neural networks
@@ -1,15 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- # Setting Up
4
-
5
- setup(
6
-
7
- name = "pyerualjetwork",
8
- version = "1.2.8",
9
- author = "Hasan Can Beydili",
10
- author_email = "tchasancan@gmail.com",
11
- description= "Advanced python deep learning library. 'ThresholdSigns' changed to 'MembranThresholds' and 'ThresholdValues' changed to 'MembranPotentials'. (Documentation in desc. Examples in GİTHUB: https://github.com/HCB06/PyerualJetwork)",
12
- packages = find_packages(),
13
- keywords = ["model evaluation", "classifcation", 'pruning learning artficial neural networks']
14
-
15
- )
File without changes