PyHierarchicalTsetlinMachineCUDA 0.2.9__tar.gz → 0.3.1__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.
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PKG-INFO +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/kernels.py +18 -10
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/tm.py +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/PKG-INFO +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/setup.py +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/LICENSE +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/__init__.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/tools.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/utils.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/SOURCES.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/dependency_links.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/requires.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/top_level.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/README.md +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.2.9 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/setup.cfg +0 -0
|
@@ -321,15 +321,13 @@ code_update = """
|
|
|
321
321
|
int index = blockIdx.x * blockDim.x + threadIdx.x;
|
|
322
322
|
int stride = blockDim.x * gridDim.x;
|
|
323
323
|
|
|
324
|
-
int
|
|
324
|
+
int child_input_sum;
|
|
325
325
|
|
|
326
326
|
/* Copy state to local memory for efficiency */
|
|
327
327
|
curandState localState = state[index];
|
|
328
328
|
|
|
329
329
|
// If a group node is false, all children are made false.
|
|
330
330
|
for (int group_node = index; group_node < CLAUSES*number_of_group_nodes; group_node += stride) {
|
|
331
|
-
int number_of_non_zero_children = 0;
|
|
332
|
-
|
|
333
331
|
#if LOG_SCALE == 1
|
|
334
332
|
if (group_node_output[group_node] == -1) {
|
|
335
333
|
for (int or_addend = 0; or_addend < number_of_group_node_children; ++or_addend) {
|
|
@@ -342,10 +340,10 @@ code_update = """
|
|
|
342
340
|
}
|
|
343
341
|
}
|
|
344
342
|
} else {
|
|
343
|
+
child_input_sum = 0;
|
|
345
344
|
for (int or_addend = 0; or_addend < number_of_group_node_children; ++or_addend) {
|
|
346
345
|
if (child_input[group_node*number_of_group_node_children + or_addend] >= 0) {
|
|
347
|
-
|
|
348
|
-
number_of_non_zero_children++;
|
|
346
|
+
child_input_sum += np.exp2f(child_input[group_node*number_of_group_node_children + or_addend]); // Needs normalization
|
|
349
347
|
}
|
|
350
348
|
}
|
|
351
349
|
}
|
|
@@ -361,23 +359,33 @@ code_update = """
|
|
|
361
359
|
}
|
|
362
360
|
}
|
|
363
361
|
} else {
|
|
362
|
+
child_input_sum = 0;
|
|
364
363
|
for (int or_addend = 0; or_addend < number_of_group_node_children; ++or_addend) {
|
|
365
|
-
if (child_input[group_node*number_of_group_node_children + or_addend] > 0) {
|
|
366
|
-
|
|
367
|
-
number_of_non_zero_children++;
|
|
364
|
+
if (child_input[group_node*number_of_group_node_children + or_addend] > 0) {
|
|
365
|
+
child_input_sum += child_input[group_node*number_of_group_node_children + or_addend];
|
|
368
366
|
}
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
369
|
#endif
|
|
372
370
|
|
|
371
|
+
// Skip node if "turned off" (-1)
|
|
373
372
|
if (group_node_output[group_node] != -1) {
|
|
374
373
|
int selected_child;
|
|
375
|
-
if (
|
|
376
|
-
|
|
374
|
+
if (child_input_sum > 0) {
|
|
375
|
+
int random_child_value = curand(&localState) % child_input_sum;
|
|
376
|
+
child_input_sum = 0;
|
|
377
|
+
for (int or_addend = 0; or_addend < number_of_group_node_children; ++or_addend) {
|
|
378
|
+
child_input_sum += child_input[group_node*number_of_group_node_children + or_addend];
|
|
379
|
+
if (child_input_sum > random_child_value) {
|
|
380
|
+
selected_child = or_addend;
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
377
384
|
} else {
|
|
378
385
|
selected_child = curand(&localState) % number_of_group_node_children;
|
|
379
386
|
}
|
|
380
387
|
|
|
388
|
+
// "Turn off" the sub-hierarchies that were not selected
|
|
381
389
|
for (int or_addend = 0; or_addend < number_of_group_node_children; ++or_addend) {
|
|
382
390
|
if (selected_child != or_addend) {
|
|
383
391
|
child_input[group_node*number_of_group_node_children + or_addend] = -1;
|
|
@@ -100,7 +100,7 @@ class CommonTsetlinMachine():
|
|
|
100
100
|
# Calculates number of literal chunks overall for the feature vector (ignores OR- and AND alternatives)
|
|
101
101
|
self.number_of_literal_chunks = self.number_of_literal_chunks_per_leaf
|
|
102
102
|
for d in range(self.depth - 1, 0, -1):
|
|
103
|
-
if (self.hierarchy_structure[d][0] == OR_GROUP or self.hierarchy_structure[d][0] == AND_GROUP):
|
|
103
|
+
if (self.hierarchy_structure[d][0] == OR_GROUP or self.hierarchy_structure[d][0] == AND_GROUP): # OR_GROUP and AND_GROUP join the features of their children
|
|
104
104
|
self.number_of_literal_chunks *= self.hierarchy_structure[d][1]
|
|
105
105
|
|
|
106
106
|
self.np_rng = np.random.default_rng(seed)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|