PyHierarchicalTsetlinMachineCUDA 0.2.6__tar.gz → 0.2.7__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.
Files changed (15) hide show
  1. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PKG-INFO +1 -1
  2. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA/kernels.py +8 -2
  3. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA/tm.py +10 -4
  4. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA.egg-info/PKG-INFO +1 -1
  5. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/README.md +5 -5
  6. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/setup.py +1 -1
  7. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/LICENSE +0 -0
  8. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA/__init__.py +0 -0
  9. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA/tools.py +0 -0
  10. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA/utils.py +0 -0
  11. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA.egg-info/SOURCES.txt +0 -0
  12. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA.egg-info/dependency_links.txt +0 -0
  13. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA.egg-info/requires.txt +0 -0
  14. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/PyHierarchicalTsetlinMachineCUDA.egg-info/top_level.txt +0 -0
  15. {PyHierarchicalTsetlinMachineCUDA-0.2.6 → PyHierarchicalTsetlinMachineCUDA-0.2.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyHierarchicalTsetlinMachineCUDA
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Hierarchical Tsetlin Machine Architecture.
5
5
  Home-page: https://github.com/cair/PyHierarchicalTsetlinMachineCUDA/
6
6
  Author: Ole-Christoffer Granmo
@@ -238,7 +238,7 @@ code_update = """
238
238
  }
239
239
  }
240
240
 
241
- // or_group_node_output[or_group_node] = or_group_vote_sum;
241
+ //or_group_node_output[or_group_node] = or_group_vote_sum;
242
242
  or_group_node_output[or_group_node] = max_vote_sum;
243
243
  }
244
244
  }
@@ -252,12 +252,17 @@ code_update = """
252
252
  for (int and_group_node = index; and_group_node < CLAUSES*number_of_and_group_nodes; and_group_node += stride) {
253
253
  // Multiply and factors
254
254
  int and_group_vote_product = 1;
255
+ int max_vote_sum = 0;
255
256
  for (int and_factor = 0; and_factor < number_of_and_group_factors; ++and_factor) {
256
257
  // Aggregate votes from each child node through multiplication
257
258
 
258
259
  int previous_and_group_vote_product = and_group_vote_product;
259
260
  and_group_vote_product *= child_input[and_group_node*number_of_and_group_factors + and_factor];
260
261
 
262
+ if (child_input[and_group_node*number_of_and_group_factors + and_factor] > max_vote_sum) {
263
+ max_vote_sum = child_input[and_group_node*number_of_and_group_factors + and_factor];
264
+ }
265
+
261
266
  if (and_group_vote_product < 0) {
262
267
  printf("AND OVERFLOW %d -> %d\\n", previous_and_group_vote_product, and_group_vote_product);
263
268
  and_group_vote_product = previous_and_group_vote_product;
@@ -266,6 +271,7 @@ code_update = """
266
271
 
267
272
  // Store and group product as node output
268
273
  and_group_node_output[and_group_node] = and_group_vote_product;
274
+ //and_group_node_output[and_group_node] = max_vote_sum;
269
275
  }
270
276
  }
271
277
 
@@ -583,7 +589,7 @@ code_clauses = """
583
589
  int index = blockIdx.x * blockDim.x + threadIdx.x;
584
590
  int stride = blockDim.x * gridDim.x;
585
591
 
586
- for (unsigned long long i = index; i < CLAUSES * COMPONENTS * LITERALS_PER_LEAF; i += stride) {
592
+ for (unsigned long long i = index; i < 1LLU * CLAUSES * COMPONENTS * LITERALS_PER_LEAF; i += stride) {
587
593
  unsigned long long clause = i / (COMPONENTS * LITERALS_PER_LEAF);
588
594
  unsigned long long comp = (i / LITERALS_PER_LEAF) % COMPONENTS;
589
595
  unsigned long long ta_idx = i % LITERALS_PER_LEAF;
@@ -539,10 +539,16 @@ class CommonTsetlinMachine():
539
539
  left = []
540
540
  right = []
541
541
  inside = []
542
+ feature_base = 0
543
+ size = self.hierarchy_structure[0][1]
542
544
  for d in range(1, self.depth):
543
545
  depth_d_node_index = component_remainder % self.hierarchy_structure[d][1]
544
546
  component_remainder = component_remainder // self.hierarchy_structure[d][1]
545
547
 
548
+ if self.hierarchy_structure[d][0] != OR_ALTERNATIVES:
549
+ feature_base += size * depth_d_node_index
550
+ size *= self.hierarchy_structure[d][1];
551
+
546
552
  if previous_index[d-1] == -1:
547
553
  left.append("(")
548
554
  elif depth_d_node_index == 0 and previous_index[d-1] != depth_d_node_index:
@@ -567,14 +573,14 @@ class CommonTsetlinMachine():
567
573
  if self.ta_action(i, j, k):
568
574
  if k < self.number_of_literals_per_leaf // 2:
569
575
  if print_ta_state:
570
- l.append("x%d(%d)" % (k, self.ta_state(i, j, k)))
576
+ l.append("x%d(%d)" % (feature_base + k, self.ta_state(i, j, k)))
571
577
  else:
572
- l.append("x%d" % (k,))
578
+ l.append("x%d" % (feature_base + k,))
573
579
  else:
574
580
  if print_ta_state:
575
- l.append("¬x%d(%d)" % (k - self.number_of_literals_per_leaf // 2, self.ta_state(i, j, k)))
581
+ l.append("¬x%d(%d)" % (feature_base + k - self.number_of_literals_per_leaf // 2, self.ta_state(i, j, k)))
576
582
  else:
577
- l.append("¬x%d" % (k - self.number_of_literals_per_leaf // 2,))
583
+ l.append("¬x%d" % (feature_base + k - self.number_of_literals_per_leaf // 2,))
578
584
 
579
585
  if len(l) > 1:
580
586
  print("(" + " ∧ ".join(l) + ")", end = '')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyHierarchicalTsetlinMachineCUDA
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: Hierarchical Tsetlin Machine Architecture.
5
5
  Home-page: https://github.com/cair/PyHierarchicalTsetlinMachineCUDA/
6
6
  Author: Ole-Christoffer Granmo
@@ -1,10 +1,6 @@
1
1
  # Hierarchical Tsetlin Machine in CUDA
2
2
  Implements the [Hierarchical Tsetlin Machine](https://github.com/cair/HierarchicalTsetlinMachine) in CUDA.
3
3
 
4
- <p align="center">
5
- <img width="60%" src="https://github.com/cair/PyHierarchicalTsetlinMachineCUDA/blob/main/figures/Visualization_voting.png">
6
- </p>
7
-
8
4
  ## Installation
9
5
 
10
6
  ```bash
@@ -15,13 +11,17 @@ or
15
11
  git clone git@github.com:cair/PyHierarchicalTsetlinMachineCUDA.git
16
12
  cd PyHierarchicalTsetlinMachineCUDA
17
13
  python ./setup.py sdist
18
- pip install dist/PyHierarchicalTsetlinMachineCUDA-0.2.2.tar.gz
14
+ pip install dist/PyHierarchicalTsetlinMachineCUDA-0.2.6.tar.gz
19
15
  ```
20
16
 
21
17
  ## Examples
22
18
 
23
19
  ### Noisy Parity Demo
24
20
 
21
+ <p align="center">
22
+ <img width="60%" src="https://github.com/cair/PyHierarchicalTsetlinMachineCUDA/blob/main/figures/Visualization_voting.png">
23
+ </p>
24
+
25
25
  #### Code: NoisyParityDemo.py
26
26
 
27
27
  ```python
@@ -2,7 +2,7 @@ from setuptools import *
2
2
 
3
3
  setup(
4
4
  name='PyHierarchicalTsetlinMachineCUDA',
5
- version='0.2.6',
5
+ version='0.2.7',
6
6
  author='Ole-Christoffer Granmo',
7
7
  author_email='ole.granmo@uia.no',
8
8
  url='https://github.com/cair/PyHierarchicalTsetlinMachineCUDA/',