cair / PyTsetlinMachineCUDA

Massively Parallel and Asynchronous Architecture for Logic-based AI
https://arxiv.org/abs/2009.04861
MIT License
41 stars 4 forks source link

Special case on update? #2

Closed pedritolo closed 4 years ago

pedritolo commented 4 years ago

Hi I'm not sure if this a bug, perhaps you'll figure it out quickly. In cuda "update" function, in this block of code,

                // Evaluate each patch (convolution)
                output_one_patches_count = 0;
                for (int patch = 0; patch < PATCHES; ++patch) {
                    int patch_clause_output = 1;
                    for (int la_chunk = 0; la_chunk < LA_CHUNKS-1; ++la_chunk) {
                        if ((ta_state[la_chunk*STATE_BITS + STATE_BITS - 1] & X[e*(LA_CHUNKS*PATCHES) + patch*LA_CHUNKS + la_chunk]) != ta_state[la_chunk*STATE_BITS + STATE_BITS - 1]) {
                            patch_clause_output = 0;
                            break;
                        }
                    }

                    if (((ta_state[(LA_CHUNKS-1)*STATE_BITS + STATE_BITS - 1] & X[e*(LA_CHUNKS*PATCHES) + patch*LA_CHUNKS + LA_CHUNKS - 1] & FILTER) != (ta_state[(LA_CHUNKS-1)*STATE_BITS + STATE_BITS - 1] & FILTER))) {
                        patch_clause_output = 0;
                    }

consider the special case where the automata's mask is 0 for all la chunks. That will make patch_clause_output remain == 1, is that intended behavior?

olegranmo commented 4 years ago

Keen observation! Yes, it is a special case for update. For update, "empty" clauses evaluate to 1, while for predict, empty clauses evaluate to 0.