PyHierarchicalTsetlinMachineCUDA 0.3.0__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.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PKG-INFO +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/kernels.py +18 -10
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/tm.py +1 -9
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/PKG-INFO +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/setup.py +1 -1
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/LICENSE +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/__init__.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/tools.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA/utils.py +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/SOURCES.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/dependency_links.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/requires.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/PyHierarchicalTsetlinMachineCUDA.egg-info/top_level.txt +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → PyHierarchicalTsetlinMachineCUDA-0.3.1}/README.md +0 -0
- {PyHierarchicalTsetlinMachineCUDA-0.3.0 → 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;
|
|
@@ -97,12 +97,6 @@ class CommonTsetlinMachine():
|
|
|
97
97
|
if self.hierarchy_structure[d][0] != OR_GROUP: # OR_GROUP reuses the same TA
|
|
98
98
|
self.number_of_ta_teams = self.hierarchy_structure[self.depth - d - 1][1] * self.number_of_ta_teams
|
|
99
99
|
|
|
100
|
-
# Identifies the larget number of OR_GROUP children (for allocating local memory)
|
|
101
|
-
self.max_number_of_or_group_children = 0
|
|
102
|
-
for d in range(1, self.depth):
|
|
103
|
-
if self.hierarchy_structure[d][0] == OR_GROUP and self.max_number_of_or_group_children < self.hierarchy_structure[d][1]:
|
|
104
|
-
self.max_number_of_or_group_children = self.hierarchy_structure[d][1]
|
|
105
|
-
|
|
106
100
|
# Calculates number of literal chunks overall for the feature vector (ignores OR- and AND alternatives)
|
|
107
101
|
self.number_of_literal_chunks = self.number_of_literal_chunks_per_leaf
|
|
108
102
|
for d in range(self.depth - 1, 0, -1):
|
|
@@ -140,11 +134,9 @@ class CommonTsetlinMachine():
|
|
|
140
134
|
#define OR_GROUP %d
|
|
141
135
|
#define OR_ALTERNATIVES %d
|
|
142
136
|
|
|
143
|
-
#define MAX_NUMBER_OF_OR_GROUP_CHILDREN %d
|
|
144
|
-
|
|
145
137
|
#define NEGATIVE_CLAUSES %d
|
|
146
138
|
#define FLIP_POLARITY %d
|
|
147
|
-
""" % (self.number_of_clauses, self.depth, self.hierarchy_size[1], self.number_of_ta_teams, self.number_of_literals_per_leaf, self.number_of_literal_chunks_per_leaf, self.number_of_literal_chunks, self.number_of_state_bits, self.boost_true_positive_feedback, self.s, self.T, self.q, self.log_scale, AND_GROUP, AND_ALTERNATIVES, OR_GROUP, OR_ALTERNATIVES, self.
|
|
139
|
+
""" % (self.number_of_clauses, self.depth, self.hierarchy_size[1], self.number_of_ta_teams, self.number_of_literals_per_leaf, self.number_of_literal_chunks_per_leaf, self.number_of_literal_chunks, self.number_of_state_bits, self.boost_true_positive_feedback, self.s, self.T, self.q, self.log_scale, AND_GROUP, AND_ALTERNATIVES, OR_GROUP, OR_ALTERNATIVES, self.negative_clauses, self.flip_polarity)
|
|
148
140
|
|
|
149
141
|
mod_prepare = SourceModule(parameters + kernels.code_header + kernels.code_prepare, no_extern_c=True)
|
|
150
142
|
self.prepare_weights = mod_prepare.get_function("prepare_weights")
|
|
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
|