Giter Club home page Giter Club logo

cair / tmu Goto Github PK

View Code? Open in Web Editor NEW
110.0 7.0 8.0 254.03 MB

Implements the Tsetlin Machine, Coalesced Tsetlin Machine, Convolutional Tsetlin Machine, Regression Tsetlin Machine, and Weighted Tsetlin Machine, with support for continuous features, drop clause, Type III Feedback, focused negative sampling, multi-task classifier, autoencoder, literal budget, and one-vs-one multi-class classifier. TMU is written in Python with wrappers for C and CUDA-based clause evaluation and updating.

Home Page: https://pypi.org/project/tmu/

License: MIT License

Python 64.37% C 14.54% Cuda 4.84% CMake 0.98% C++ 15.08% Shell 0.19%
tsetlin-machine convolution regression multi-output pattern-recognition propositional-logic relational-logic cuda gpu incremental

tmu's Introduction

Tsetlin Machine Unified (TMU) - One Codebase to Rule Them All

License Python Version Maintenance

TMU is a comprehensive repository that encompasses several Tsetlin Machine implementations. Offering a rich set of features and extensions, it serves as a central resource for enthusiasts and researchers alike.

Features

Guides and Tutorials

📦 Installation

Prerequisites for Windows

Before installing TMU on Windows, ensure you have the MSVC build tools. Follow these steps:

  1. Download MSVC build tools
  2. Install the Workloads → Desktop development with C++ package. (Note: The package size is about 6-7GB.)

Dependencies

Ubuntu: sudo apt install libffi-dev

Installing TMU

To get started with TMU, run the following command:

# Installing Stable Branch
pip install git+https://github.com/cair/tmu.git

# Installing Development Branch
pip install git+https://github.com/cair/tmu.git@dev

🛠 Development

If you're looking to contribute or experiment with the codebase, follow these steps:

  1. Clone the Repository:

    git clone -b dev [email protected]:cair/tmu.git && cd tmu
  2. Set Up Development Environment: Navigate to the project directory and compile the C library:

    # Install TMU
     pip install .
    
    # (Alternative): Install TMU in Development Mode
     pip install -e .
    
    # Install TMU-Composite
     pip install .[composite]
    
    # Install TMU-Composite in Development Mode
     pip install -e .[composite]
  3. Starting a New Project: For your projects, simply create a new branch and then within the 'examples' folder, create a new project and initiate your development.


tmu's People

Contributors

olegranmo avatar perara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmu's Issues

Compilation error on Mac

  In file included from tmu/tmulib.c:2194:
  /Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/include/immintrin.h:14:2: error: "This header is only meant to be used on x86 and x64 architecture"
  #error "This header is only meant to be used on x86 and x64 architecture"

AutoEncoder has stopped learning

Here is the incorrect output after one epoch:

awful: brilliant(0.93) scary(0.92) horrifying(0.91) witty(0.91) car(0.90) superb(0.90) crap(0.90) abysmal(0.90) funny(0.90) magnificent(0.90) hilarious(0.90) frightening(0.89) lousy(0.89) outstanding(0.89) terrible(0.89) marvellous(0.89) comic(0.88) cars(0.88) plane(0.88) truck(0.87) terrifying(0.87) excellent(0.86) motorcycle(0.85)
terrible: comic(0.93) horrifying(0.93) marvellous(0.92) truck(0.92) magnificent(0.92) superb(0.92) abysmal(0.91) excellent(0.91) brilliant(0.90) funny(0.90) terrifying(0.90) outstanding(0.90) hilarious(0.90) witty(0.90) car(0.89) frightening(0.89) lousy(0.89) cars(0.89) plane(0.89) awful(0.89) motorcycle(0.88) scary(0.88) crap(0.86)
lousy: comic(0.94) horrifying(0.93) hilarious(0.92) magnificent(0.92) cars(0.92) brilliant(0.92) frightening(0.91) funny(0.91) outstanding(0.91) excellent(0.91) abysmal(0.91) superb(0.91) truck(0.90) scary(0.90) plane(0.89) car(0.89) awful(0.89) terrible(0.89) marvellous(0.89) crap(0.88) witty(0.88) terrifying(0.88) motorcycle(0.87)
abysmal: comic(0.93) frightening(0.93) horrifying(0.92) witty(0.92) outstanding(0.92) plane(0.92) truck(0.91) cars(0.91) terrible(0.91) excellent(0.91) lousy(0.91) funny(0.90) car(0.90) magnificent(0.90) brilliant(0.90) hilarious(0.90) marvellous(0.90) superb(0.90) awful(0.90) crap(0.89) motorcycle(0.89) terrifying(0.89) scary(0.87)
crap: excellent(0.92) hilarious(0.91) witty(0.91) comic(0.90) brilliant(0.90) awful(0.90) funny(0.90) abysmal(0.89) frightening(0.89) cars(0.89) plane(0.89) outstanding(0.89) scary(0.89) magnificent(0.88) lousy(0.88) horrifying(0.88) car(0.87) superb(0.87) terrible(0.86) truck(0.85) terrifying(0.84) marvellous(0.84) motorcycle(0.84)
outstanding: comic(0.95) magnificent(0.94) excellent(0.94) brilliant(0.92) superb(0.92) witty(0.92) horrifying(0.92) terrifying(0.92) truck(0.92) plane(0.92) abysmal(0.92) funny(0.92) marvellous(0.91) lousy(0.91) hilarious(0.90) scary(0.90) terrible(0.90) frightening(0.90) cars(0.89) crap(0.89) awful(0.89) car(0.88) motorcycle(0.87)
brilliant: witty(0.94) excellent(0.94) awful(0.93) cars(0.93) motorcycle(0.92) outstanding(0.92) scary(0.92) horrifying(0.92) magnificent(0.92) comic(0.92) lousy(0.92) superb(0.91) car(0.91) marvellous(0.91) funny(0.90) hilarious(0.90) crap(0.90) terrible(0.90) abysmal(0.90) truck(0.90) plane(0.90) terrifying(0.89) frightening(0.89)
excellent: outstanding(0.94) brilliant(0.94) comic(0.94) truck(0.93) magnificent(0.93) plane(0.93) horrifying(0.93) witty(0.93) crap(0.92) marvellous(0.92) superb(0.92) cars(0.91) funny(0.91) motorcycle(0.91) scary(0.91) hilarious(0.91) abysmal(0.91) lousy(0.91) terrible(0.91) terrifying(0.90) frightening(0.90) car(0.89) awful(0.86)
superb: magnificent(0.95) marvellous(0.94) horrifying(0.93) outstanding(0.92) comic(0.92) funny(0.92) witty(0.92) excellent(0.92) cars(0.92) truck(0.92) terrible(0.92) plane(0.91) hilarious(0.91) brilliant(0.91) scary(0.91) lousy(0.91) terrifying(0.91) awful(0.90) abysmal(0.90) frightening(0.89) motorcycle(0.89) crap(0.87) car(0.86)
magnificent: comic(0.95) superb(0.95) horrifying(0.95) outstanding(0.94) funny(0.94) terrifying(0.94) witty(0.93) excellent(0.93) scary(0.92) lousy(0.92) brilliant(0.92) truck(0.92) terrible(0.92) marvellous(0.91) cars(0.91) plane(0.91) abysmal(0.90) frightening(0.90) awful(0.90) hilarious(0.89) car(0.89) crap(0.88) motorcycle(0.86)
marvellous: truck(0.94) superb(0.94) horrifying(0.93) scary(0.93) comic(0.92) plane(0.92) funny(0.92) excellent(0.92) terrible(0.92) cars(0.91) magnificent(0.91) outstanding(0.91) motorcycle(0.91) witty(0.91) brilliant(0.91) car(0.91) abysmal(0.90) frightening(0.90) terrifying(0.89) hilarious(0.89) lousy(0.89) awful(0.89) crap(0.84)
truck: marvellous(0.94) comic(0.93) excellent(0.93) scary(0.93) witty(0.93) plane(0.92) car(0.92) horrifying(0.92) funny(0.92) magnificent(0.92) outstanding(0.92) terrible(0.92) superb(0.92) abysmal(0.91) cars(0.91) lousy(0.90) frightening(0.90) brilliant(0.90) terrifying(0.90) motorcycle(0.88) awful(0.87) hilarious(0.86) crap(0.85)
plane: horrifying(0.93) excellent(0.93) truck(0.92) frightening(0.92) marvellous(0.92) outstanding(0.92) abysmal(0.92) superb(0.91) witty(0.91) magnificent(0.91) comic(0.91) funny(0.90) brilliant(0.90) scary(0.89) lousy(0.89) cars(0.89) car(0.89) crap(0.89) hilarious(0.89) terrible(0.89) motorcycle(0.89) terrifying(0.88) awful(0.88)
car: funny(0.93) truck(0.92) comic(0.92) witty(0.92) brilliant(0.91) scary(0.91) marvellous(0.91) abysmal(0.90) cars(0.90) horrifying(0.90) awful(0.90) frightening(0.89) lousy(0.89) plane(0.89) terrible(0.89) magnificent(0.89) excellent(0.89) hilarious(0.89) outstanding(0.88) motorcycle(0.88) terrifying(0.87) crap(0.87) superb(0.86)
cars: comic(0.93) brilliant(0.93) funny(0.92) lousy(0.92) superb(0.92) witty(0.92) excellent(0.91) abysmal(0.91) marvellous(0.91) magnificent(0.91) truck(0.91) horrifying(0.90) car(0.90) scary(0.89) outstanding(0.89) plane(0.89) motorcycle(0.89) crap(0.89) frightening(0.89) terrible(0.89) hilarious(0.88) awful(0.88) terrifying(0.86)
motorcycle: brilliant(0.92) excellent(0.91) marvellous(0.91) horrifying(0.90) frightening(0.89) terrifying(0.89) abysmal(0.89) cars(0.89) superb(0.89) plane(0.89) comic(0.88) terrible(0.88) truck(0.88) hilarious(0.88) witty(0.88) car(0.88) outstanding(0.87) funny(0.87) lousy(0.87) magnificent(0.86) scary(0.85) awful(0.85) crap(0.84)
scary: funny(0.93) marvellous(0.93) truck(0.93) witty(0.92) awful(0.92) brilliant(0.92) magnificent(0.92) horrifying(0.91) excellent(0.91) car(0.91) superb(0.91) frightening(0.91) comic(0.91) lousy(0.90) outstanding(0.90) terrifying(0.90) cars(0.89) plane(0.89) crap(0.89) terrible(0.88) hilarious(0.87) abysmal(0.87) motorcycle(0.85)
frightening: abysmal(0.93) horrifying(0.93) plane(0.92) terrifying(0.91) lousy(0.91) comic(0.91) witty(0.91) scary(0.91) truck(0.90) marvellous(0.90) excellent(0.90) outstanding(0.90) magnificent(0.90) motorcycle(0.89) hilarious(0.89) car(0.89) awful(0.89) crap(0.89) superb(0.89) cars(0.89) terrible(0.89) funny(0.89) brilliant(0.89)
terrifying: magnificent(0.94) outstanding(0.92) comic(0.92) frightening(0.91) superb(0.91) excellent(0.90) terrible(0.90) truck(0.90) scary(0.90) marvellous(0.89) motorcycle(0.89) abysmal(0.89) brilliant(0.89) horrifying(0.89) witty(0.89) lousy(0.88) plane(0.88) funny(0.88) car(0.87) awful(0.87) hilarious(0.86) cars(0.86) crap(0.84)
horrifying: magnificent(0.95) marvellous(0.93) plane(0.93) frightening(0.93) excellent(0.93) superb(0.93) lousy(0.93) terrible(0.93) comic(0.92) truck(0.92) brilliant(0.92) abysmal(0.92) funny(0.92) witty(0.92) outstanding(0.92) scary(0.91) hilarious(0.91) awful(0.91) cars(0.90) motorcycle(0.90) car(0.90) terrifying(0.89) crap(0.88)
funny: comic(0.95) magnificent(0.94) car(0.93) scary(0.93) truck(0.92) marvellous(0.92) superb(0.92) cars(0.92) horrifying(0.92) witty(0.92) outstanding(0.92) excellent(0.91) lousy(0.91) hilarious(0.91) brilliant(0.90) abysmal(0.90) plane(0.90) terrible(0.90) crap(0.90) awful(0.90) frightening(0.89) terrifying(0.88) motorcycle(0.87)
comic: outstanding(0.95) funny(0.95) magnificent(0.95) lousy(0.94) excellent(0.94) abysmal(0.93) truck(0.93) cars(0.93) terrible(0.93) witty(0.92) horrifying(0.92) marvellous(0.92) car(0.92) brilliant(0.92) superb(0.92) terrifying(0.92) hilarious(0.91) frightening(0.91) plane(0.91) scary(0.91) crap(0.90) motorcycle(0.88) awful(0.88)
hilarious: lousy(0.92) witty(0.92) superb(0.91) comic(0.91) excellent(0.91) crap(0.91) horrifying(0.91) funny(0.91) brilliant(0.90) outstanding(0.90) abysmal(0.90) awful(0.90) terrible(0.90) magnificent(0.89) frightening(0.89) marvellous(0.89) plane(0.89) car(0.89) cars(0.88) motorcycle(0.88) scary(0.87) truck(0.86) terrifying(0.86)
witty: brilliant(0.94) magnificent(0.93) truck(0.93) excellent(0.93) comic(0.92) scary(0.92) outstanding(0.92) superb(0.92) abysmal(0.92) horrifying(0.92) cars(0.92) car(0.92) hilarious(0.92) funny(0.92) frightening(0.91) plane(0.91) marvellous(0.91) crap(0.91) awful(0.91) terrible(0.90) terrifying(0.89) lousy(0.88) motorcycle(0.88)

No support for tracking results during training (tm.fit())

There is no support for tracking loss/accuracy during training and testing of the tsetlin machine. The only data that is available is the end results. It would be helpful to see the data as the machine is training to gain insight in how the machine learns over time.

CUDA error when installing with non-local pip install

This error does not occur with local install (pip3 install -e .), however, occurs with remote install (pip3 install tmu):

2023-04-17 06:40:30,320 - tmu.models.classification.vanilla_classifier - DEBUG - Initializing clause bank....
Traceback (most recent call last):
File "./examples/experimental/classification/IMDbWordPredictionConvolutionDemo.py", line 125, in
tm.fit(X_train, Y_train)
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/models/classification/vanilla_classifier.py", line 148, in fit
self.init(X, Y)
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/models/classification/base_classification.py", line 32, in init
self.init_clause_bank(X, Y)
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/models/classification/vanilla_classifier.py", line 126, in init_clause_bank
self.clause_banks = [clause_bank_type(**clause_bank_args) for _ in range(self.number_of_classes)]
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/models/classification/vanilla_classifier.py", line 126, in
self.clause_banks = [clause_bank_type(**clause_bank_args) for _ in range(self.number_of_classes)]
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/clause_bank/clause_bank_cuda.py", line 92, in init
mod = load_cuda_kernel(parameters, "cuda/calculate_clause_outputs_predict.cu")
File "/home/oleg/.local/lib/python3.8/site-packages/tmu/clause_bank/clause_bank_cuda.py", line 55, in load_cuda_kernel
with path.open("r") as f:
File "/usr/lib/python3.8/pathlib.py", line 1222, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/usr/lib/python3.8/pathlib.py", line 1078, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/oleg/.local/lib/python3.8/site-packages/tmu/clause_bank/cuda/calculate_clause_outputs_predict.cu'

Saving and loading trained classifiers

Hey there,

I'm playing around with the Tsetlin classifier and I'm having some trouble figuring out how to save a trained classifier so that it can be loaded later. Do you have a go-to method that you can recommend? I couldn't do it with pickle and joblib. So I tried pickling the clause banks and weight banks separately but that seems to work only if I pickle them before the classifier is used for any prediction which in my case is not an option.

I'm attaching a minimal example just in case but I imagine there must be another way to do it that I haven't figured out.

saving.py

import pickle
from tmu.models.classification.vanilla_classifier import TMClassifier
from tmu.data import TMUDatasetSource

data = TMUDatasetSource().get_dataset(
        "XOR_biased",
        cache=True,
        cache_max_age=1,
        features=["X", "Y"],
        labels=["xor"],
        shuffle=True,
        train_ratio=1000,
        test_ratio=1000,
        return_type=dict
    )

tm = TMClassifier(20,10,2)
tm.fit(data["x_train"], data["y_train"])

# This method works only if these two lines are commented out:
# y_pred = tm.predict(data["x_test"])
# print((y_pred == data["y_test"]).mean())

for i in range(len(tm.weight_banks)):
    with open('wb%s.pkl' % i, 'wb') as f:
        pickle.dump(tm.weight_banks[i], f)
for i in range(len(tm.clause_banks)):
    with open('cb%s.pkl' % i, 'wb') as f:
        pickle.dump(tm.clause_banks[i], f)

loading.py

from tmu.models.classification.vanilla_classifier import TMClassifier
from tmu.data import TMUDatasetSource
import os
import pickle

data = TMUDatasetSource().get_dataset(
        "XOR_biased",
        cache=True,
        cache_max_age=1,
        features=["X", "Y"],
        labels=["xor"],
        shuffle=True,
        train_ratio=1000,
        test_ratio=1000,
        return_type=dict
    )

tm_new = TMClassifier(20,10,2)
tm_new.clause_banks = []
tm_new.number_of_classes = 2
tm_new.weight_banks = []

files = os.listdir('/home/folder/')
cb_count = sum(1 for file in files if file.startswith('cb'))
wb_count = sum(1 for file in files if file.startswith('wb'))

for i in range(wb_count):
    with open('wb%s.pkl' % i, 'rb') as f:
        wb = pickle.load(f)
        tm_new.weight_banks.append(wb)
for i in range(cb_count):
    with open('cb%s.pkl' % i, 'rb') as f:
        cb = pickle.load(f)
        tm_new.clause_banks.append(cb)

y_pred_new = tm_new.predict(data["x_test"])
print((y_pred_new == data["y_test"]).mean())

The error that I get when I first predict something and then save the clause and weight banks is the following:

Traceback (most recent call last):
  File "loading.py", line 36, in <module>
    y_pred_new = tm_new.predict(data["x_test"])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/envs/tmtest/lib/python3.11/site-packages/tmu/models/classification/vanilla_classifier.py", line 311, in predict
    self.clause_banks[i].calculate_clause_outputs_predict(self.encoded_X_test,
  File "/home/envs/tmtest/lib/python3.11/site-packages/tmu/clause_bank/clause_bank.py", line 168, in calculate_clause_outputs_predict
    self.lcm_p,
    ^^^^^^^^^^
AttributeError: 'ClauseBank' object has no attribute 'lcm_p'. Did you mean: 'lcc_p'?

Thanks for the help!

Single clause-bank object for all classifiers?

@olegranmo

Looking at vanilla_classifier they use a list of clause banks instead of a single object. I probably dont understand this properly, but looking at the code is seems like the self.clause_bank in coalesced_classifier instead uses the self.weight_banks to do updates:
From coalesced:

        self.clause_bank.type_i_feedback(update_p * self.type_i_p, self.s, self.boost_true_positive_feedback,
                                         self.max_included_literals,
                                         self.clause_active * (self.weight_banks[target].get_weights() >= 0),
                                         self.literal_active, self.encoded_X_train, e)```
In the vanilla classifier we have:
```python
            self.clause_banks[target].type_i_feedback(
                update_p=update_p * self.type_i_p,
                s=self.s,
                boost_true_positive_feedback=self.boost_true_positive_feedback,
                max_included_literals=self.max_included_literals,
                clause_active=clause_active[target] * self.positive_clauses,
                literal_active=literal_active,
                encoded_X=self.encoded_X_train,
                e=e
            )

Would it be possible to follow the same clause_bank style for vanilla_classifier as for rest of the models?

get_encoded_data does not refresh with new data

Had to remove the compute_hash part to make it work:

def get_encoded_data(self, data: np.ndarray, encoder_func) -> np.ndarray:
"""Get encoded data for an array, using cache if available."""

    self.encoded_data = encoder_func(data)

    return self.encoded_data

Cannot compile tools.cu

@olegranmo

CompileError: nvcc compilation of /tmp/tmpv8kz891e/kernel.cu failed
[command: nvcc --cubin -arch sm_70 -I/opt/conda/lib/python3.8/site-packages/pycuda/cuda --keep kernel.cu]
[stderr:
kernel.cu(31): error: explicit type is missing ("int" assumed)

kernel.cu(93): error: identifier "compareints" is undefined

2 errors detected in the compilation of "kernel.cu".
]```

The following occurs  when compiling tools.cu.  Any clue on how to fix this?

Issues with import and thresholding of FashionMNIST and KuzushijiMNIST datasets

There seems to be a problem with importing the FashionMNIST and KuzushijiMNIST datasets, see below.

Furthermore, I think the Booleanization of these two datasets should performed as in the following file:
https://github.com/cair/pyTsetlinMachine/blob/master/examples/FashionMNISTDemo2DConvolutionWeightedClauses.py
That is, Adaptive Gaussian thresholding procedure with window size 11 and threshold value 2, see also the original article about the Convolutional TM.


ImportError Traceback (most recent call last)
Cell In[3], line 1
----> 1 from tmu.data import FashionMNIST

ImportError: cannot import name 'FashionMNIST' from 'tmu.data' (/opt/conda/lib/python3.11/site-packages/tmu/data/init.py)

Multichannel TM not working

Traceback (most recent call last):
  File "/run/media/per/6ae969b6-0afc-498f-a39d-711ac09c8f81/git/code/tmu/examples/experimental/classification/InterpretabilityDemoAND.py", line 169, in <module>
    tm.fit(X_train, Y_train)
  File "/run/media/per/6ae969b6-0afc-498f-a39d-711ac09c8f81/git/code/tmu/tmu/models/classification/multichannel_classifier.py", line 142, in fit
    self.clause_bank.type_i_feedback(update_p * self.type_i_p, self.s[target],
TypeError: ClauseBank.type_i_feedback() missing 1 required positional argument: 'e'```

ModuleNotFoundError: No module named 'tmu.tmulib'

Looks like the new version is broken for Ubuntu?

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tmu/init.py", line 20, in
import tmu.tmulib
ModuleNotFoundError: No module named 'tmu.tmulib'

Sparse not working

File "/data/tmp/tmu/./examples/classification/IMDbSparseAbsorbingTextCategorizationDemo.py", line 92, in
tm.fit(X_train, Y_train)
File "/data/tmp/tmu/tmu/models/classification/vanilla_classifier.py", line 374, in fit
assert len(X) == len(Y), "X and Y must have the same length"
File "/usr/local/lib/python3.10/dist-packages/scipy/sparse/_base.py", line 395, in len
raise TypeError("sparse array length is ambiguous; use getnnz()"
TypeError: sparse array length is ambiguous; use getnnz() or shape[0]

Build error on Linux Ubuntu using pip3 install -e .

Building editable for tmu (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building editable for tmu (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [209 lines of output]
generating ./tmu/tmulib.c
(already up-to-date)
the current directory is '/data/tmp/tmu'
running build_ext
building 'tmu.tmulib' extension
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/data/tmp/tmu/tmu/lib/include -I/usr/include/python3.10 -c tmu/tmulib.c -o ./tmu/tmulib.o -O3 -mrdrnd
tmu/tmulib.c: In function ‘cb_type_i_feedback’:
tmu/tmulib.c:891:122: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
891 | if (clause_output && cb_number_of_include_actions(ta_state, j, number_of_literals, number_of_state_bits) <= max_included_literals) {
| ^~
tmu/tmulib.c:893:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
893 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:907:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
907 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c: In function ‘cb_type_ii_feedback’:
tmu/tmulib.c:949:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
949 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c: In function ‘cb_type_iii_feedback’:
tmu/tmulib.c:1009:59: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1009 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:1021:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1021 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:1031:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1031 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:1063:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1063 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c: In function ‘cb_initialize_incremental_clause_calculation’:
tmu/tmulib.c:1122:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1122 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:1113:22: warning: variable ‘filter’ set but not used [-Wunused-but-set-variable]
1113 | unsigned int filter;
| ^~~~~~
tmu/tmulib.c: In function ‘cb_calculate_clause_outputs_incremental_batch’:
tmu/tmulib.c:1214:22: warning: variable ‘filter’ set but not used [-Wunused-but-set-variable]
1214 | unsigned int filter;
| ^~~~~~
tmu/tmulib.c: In function ‘cb_calculate_clause_outputs_incremental’:
tmu/tmulib.c:1267:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1267 | for (int j = 0; j < literal_clause_map_pos[k] - start_pos; ++j) {
| ^
tmu/tmulib.c:1272:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1272 | for (int j = 0; j < literal_clause_map_pos[k] - start_pos; ++j) {
| ^
tmu/tmulib.c:1281:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1281 | for (int k = 0; k < number_of_ta_chunks; ++k) {
| ^
tmu/tmulib.c:1250:22: warning: variable ‘filter’ set but not used [-Wunused-but-set-variable]
1250 | unsigned int filter;
| ^~~~~~
tmu/tmulib.c: In function ‘cb_included_literals’:
tmu/tmulib.c:1378:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1378 | for (int k = 0; k < number_of_ta_chunks; k++) {
| ^
tmu/tmulib.c:1383:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1383 | for (int k = 0; k < number_of_ta_chunks; k++) {
| ^
tmu/tmulib.c: In function ‘cb_number_of_include_actions’:
tmu/tmulib.c:1408:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1408 | for (int k = 0; k < number_of_ta_chunks-1; ++k) {
| ^
tmu/tmulib.c: In function ‘tmu_produce_autoencoder_example’:
tmu/tmulib.c:1484:168: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
1484 | if ((indptr_col[active_output[target]+1] - indptr_col[active_output[target]] == 0) || (indptr_col[active_output[target]+1] - indptr_col[active_output[target]] == number_of_rows)) {
| ^~
tmu/tmulib.c:1488:57: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1488 | for (int k = indptr_row[row]; k < indptr_row[row+1]; ++k) {
| ^
tmu/tmulib.c:1507:57: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1507 | for (int k = indptr_row[row]; k < indptr_row[row+1]; ++k) {
| ^
tmu/tmulib.c:1522:187: warning: passing argument 5 of ‘bsearch’ from incompatible pointer type [-Wincompatible-pointer-types]
1522 | if (bsearch(&row, &indices_col[indptr_col[active_output[target]]], indptr_col[active_output[target]+1] - indptr_col[active_output[target]], sizeof(unsigned int), compareints) == NULL) {
| ^~~~~~~~~~~
| |
| unsigned int (*)(const void *, const void )
In file included from /usr/include/stdlib.h:833,
from /usr/include/python3.10/Python.h:34,
from tmu/tmulib.c:57:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:21:24: note: expected ‘__compar_fn_t’ {aka ‘int (
)(const void *, const void )’} but argument is of type ‘unsigned int ()(const void *, const void *)’
21 | __compar_fn_t __compar)
| ~~~~~~~~~~~~~~^~~~~~~~
tmu/tmulib.c:1523:65: warning: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]
1523 | for (int k = indptr_row[row]; k < indptr_row[row+1]; ++k) {
| ^
tmu/tmulib.c: In function ‘cbs_type_i_feedback’:
tmu/tmulib.c:1926:22: warning: unused variable ‘number_of_ta_chunks’ [-Wunused-variable]
1926 | unsigned int number_of_ta_chunks = (number_of_literals-1)/32 + 1;
| ^~~~~~~~~~~~~~~~~~~
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 ./tmu/tmulib.o -o ./tmu/tmulib.cpython-310-x86_64-linux-gnu.so
not modified: 'build/tmu/tmulib.c'
generating build/tmu/tmulib.c
(already up-to-date)
running editable_wheel
creating /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info
writing /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/dependency_links.txt
writing requirements to /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/requires.txt
writing top-level names to /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/top_level.txt
writing manifest file '/tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file '/tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu.egg-info/SOURCES.txt'
creating '/tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu-0.8.1.dist-info'
creating /tmp/pip-wheel-qzxo5pcv/.tmp-tkyet1l9/tmu-0.8.1.dist-info/WHEEL
Traceback (most recent call las
files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 267, in _run_build_commands
self._configure_build(dist_name, unpacked_wheel, build_lib, tmp_dir)
File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 217, in _configure_build
install = dist.reinitialize_command("install", reinit_subcommands=True)
File "/usr/lib/python3.10/distutils/dist.py", line 938, in reinitialize_command
command = self.get_command_obj(command_name)
File "/usr/lib/python3.10/distutils/dist.py", line 858, in get_command_obj
cmd_obj = self.command_obj[command] = klass(self)
File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/init.py", line 174, in init
super().init(dist)
File "/usr/lib/python3.10/distutils/cmd.py", line 62, in init
self.initialize_options()
File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/install.py", line 50, in initialize_options
orig.install.initialize_options(self)
File "/usr/lib/python3.10/_distutils_system_mod.py", line 33, in initialize_options
super().initialize_options()
TypeError: super(type, obj): obj must be an instance or subtype of type
/usr/lib/python3.10/distutils/dist.py:985: _DebuggingTips: Problem in editable installation.
!!

          ********************************************************************************
          An error happened while installing `tmu` in editable mode.
  
          The following steps are recommended to help debug this problem:
  
          - Try to install the project normally, without using the editable mode.
            Does the error still persist?
            (If it does, try fixing the problem before attempting the editable mode).
          - If you are using binary extensions, make sure you have all OS-level
            dependencies installed (e.g. compilers, toolchains, binary libraries, ...).
          - Try the latest version of setuptools (maybe the error was already fixed).
          - If you (or your project dependencies) are using any setuptools extension
            or customization, make sure they support the editable mode.
  
          After following the steps above, if the problem still persists and
          you think this is related to how setuptools handles editable installations,
          please submit a reproducible example
          (see https://stackoverflow.com/help/minimal-reproducible-example) to:
  
              https://github.com/pypa/setuptools/issues
  
          See https://setuptools.pypa.io/en/latest/userguide/development_mode.html for details.
          ********************************************************************************
  
  !!
    cmd_obj.run()
  Traceback (most recent call last):
    File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 273, in build_editable
      return hook(wheel_directory, config_settings, metadata_directory)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 436, in build_editable
      return self._build_with_temp_dir(
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 76, in <module>
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 103, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.10/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.10/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/dist.py", line 963, in run_command
      super().run_command(command)
    File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 156, in run
      self._create_wheel_file(bdist_wheel)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 345, in _create_wheel_file
      files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 267, in _run_build_commands
      self._configure_build(dist_name, unpacked_wheel, build_lib, tmp_dir)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 217, in _configure_build
      install = dist.reinitialize_command("install", reinit_subcommands=True)
    File "/usr/lib/python3.10/distutils/dist.py", line 938, in reinitialize_command
      command = self.get_command_obj(command_name)
    File "/usr/lib/python3.10/distutils/dist.py", line 858, in get_command_obj
      cmd_obj = self.command_obj[command] = klass(self)
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 174, in __init__
      super().__init__(dist)
    File "/usr/lib/python3.10/distutils/cmd.py", line 62, in __init__
      self.initialize_options()
    File "/tmp/pip-build-env-5tia0lvc/overlay/local/lib/python3.10/dist-packages/setuptools/command/install.py", line 50, in initialize_options
      orig.install.initialize_options(self)
    File "/usr/lib/python3.10/_distutils_system_mod.py", line 33, in initialize_options
      super().initialize_options()
  TypeError: super(type, obj): obj must be an instance or subtype of type
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building editable for tmu
Failed to build tmu
ERROR: Could not build wheels for tmu, which is required to install pyproject.toml-based projects

Request for maximum/minimum weight parameter

During testing of a hardware implementation of a Convolutional Coalesced TM – for MNIST – I found that setting a maximum/minimum value of the signed weights could give a boost in test accuracy, compared to training with no weight restrictions. In hardware such a limitation is required as a fixed number of bits per weight has to be allocated.

Typically, the weight limit would be rather small compared to the number of clauses and T, and this seems to be beneficial for the performance. It might affect the training time though.

It would be very useful and interesting if such a parameter could be included.

Support for scipy.sparse matrices

Hi, @olegranmo!
It would be very cool if methods fit, predict and transform could accept scipy.sparse matrices like most of the sklearn api models: LogisticRegression, MultinomialNB, RandomForest, etc...
For example in
https://github.com/cair/tmu/blob/main/examples/MNISTDemo.py#L18
Converting binarized X_train into scipy.sparse.csr_matrix can lower RAM consumption by a large factor.
This would be very convinient in case of relatively large datasets (with over 1 million examples). Or when there are a lot of features (like high-res images).

IMDbWordEmbeddingDemo.py not working

python3 ./examples/autoencoder/IMDbWordEmbeddingDemo.py
Could not import pycuda: No module named 'pycuda'
No module named 'pycuda'
Traceback (most recent call last):
File "/Users/oleg/Dropbox/Research/Implementations/tmp/tmu/tmu/clause_bank/clause_bank_cuda.py", line 41, in
from pycuda._driver import Device, Context
ModuleNotFoundError: No module named 'pycuda'
Could not import pycuda. This indicates that it is not installed! A possible fix is to run 'pip install pycuda'. Fallback to CPU ClauseBanks.
Hash mismatch, redownloading file
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.64M/1.64M [00:00<00:00, 6.54MiB/s]
Traceback (most recent call last):
File "/Users/oleg/Dropbox/Research/Implementations/tmp/tmu/./examples/autoencoder/IMDbWordEmbeddingDemo.py", line 194, in
main()
File "/Users/oleg/Dropbox/Research/Implementations/tmp/tmu/./examples/autoencoder/IMDbWordEmbeddingDemo.py", line 72, in main
word_to_id = dataloader.get_word_index()
File "/Users/oleg/Dropbox/Research/Implementations/tmp/tmu/tmu/data/imdb_keras.py", line 149, in get_word_index
with open(path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/oleg/.cache/tmu/datasets/imdb_word_index'

Problem with SingleClauseBankMixin, MultiWeightBankMixin?

It looks like the combination SingleClauseBankMixin, MultiWeightBankMixin only creates a single weight bank, which all the weight banks point to. I.e. the weights becomes identical for all classes in CoalescedClassifier and Autoencoder.

As a result, the ./examples/autoencoder/IMDbWordEmbeddingDemo.py and ./examples/classification/MNISTDemoCoalesced.py has stopped working. E.g., this is the output from MNISTDemoCoalesced:

2023-05-14 18:20:44,142 - main - INFO - Epoch: 1, Accuracy: 9.96, Positive clauses: 2043.0, Literals: 0.593125, Training Time: 128.10s, Testing Time: 1.18s

ModuleNotFoundError: No module named 'tmu.tmulib'

Looks like the new version is broken for Ubuntu?

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tmu/init.py", line 20, in
import tmu.tmulib
ModuleNotFoundError: No module named 'tmu.tmulib'

ndarray is not C-contiguous

Dev gives the following error when running LogicalTransformerDemo.py

Traceback (most recent call last):
File "/Users/oleg/Dropbox/Research/Implementations/LogicalTransformer/./LogicalTransformerDemo.py", line 73, in
Y_test_predicted_token, Y_test_scores_token = tms[i][j].predict(X_test_token, return_class_sums=True)
File "/Users/oleg/Dropbox/Research/Implementations/dev/tmu/tmu/models/classification/vanilla_classifier.py", line 425, in predict
encoded_X_test = self.test_encoder_cache.get_encoded_data(
File "/Users/oleg/Dropbox/Research/Implementations/dev/tmu/tmu/util/encoded_data_cache.py", line 18, in get_encoded_data
current_hash = self.compute_hash(data)
File "/Users/oleg/Dropbox/Research/Implementations/dev/tmu/tmu/util/encoded_data_cache.py", line 14, in compute_hash
return xxhash.xxh3_64_hexdigest(arr)
ValueError: ndarray is not C-contiguous

TMRegressor import error

Import error due to missing logging_example.json file.
Python 3.8.13
pip 23.0.1
5.15.0-56-generic #62~20.04.1-Ubuntu SMP
Tested on platforms: Python Tsetlin Machine, Tensorflow:22.01-tf2-py3 and PyTorch:22.04-py3

from tmu.models.regression.vanilla_regressor import TMRegressor
stacktrace:

FileNotFoundError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 from tmu.models.regression.vanilla_regressor import TMRegressor

File /opt/conda/lib/python3.8/site-packages/tmu/init.py:9, in
6 if not logging.getLogger().handlers:
7 # TODO add argparse configs here.
8 _current_file = pathlib.Path(file).parent
----> 9 with _current_file.joinpath("logging_example.json").open("r") as config_file:
10 logging.config.dictConfig(json.load(config_file))
12 try:

File /opt/conda/lib/python3.8/pathlib.py:1222, in Path.open(self, mode, buffering, encoding, errors, newline)
1220 if self._closed:
1221 self._raise_closed()
-> 1222 return io.open(self, mode, buffering, encoding, errors, newline,
1223 opener=self._opener)

File /opt/conda/lib/python3.8/pathlib.py:1078, in Path._opener(self, name, flags, mode)
1076 def _opener(self, name, flags, mode=0o666):
1077 # A stub for the opener argument to built-in open()
-> 1078 return self._accessor.open(self, flags, mode)

FileNotFoundError: [Errno 2] No such file or directory: '/opt/conda/lib/python3.8/site-packages/tmu/logging_example.json'

Request for a «set_TA_action” method

For the TMCoalescedClassifier I have used the following code to extract TA_actions per clause and weights per clause (per class).

TA_action_array= np.zeros((numberofclauses, numberofliterals), int)
for k in range (numberofclauses):
for b in range (numberofliterals):
if tm.get_ta_action(k,b) == True:
TA_action_array[k,b]=1

Weightarray=np.zeros((numberofclasses, numberofclauses), int)
for g in range (numberofclasses):
for c in range (numberofclauses):
Weightarray[g,c]=tm.get_weight(g,c)

I have used this just for extracting a trained model from the TMU – for use on hardware implementations of the TMCoalescedClassifier.

It would be great if a “set_TA_action” method could be included for the TMU, so it would be possible to manually set individual TA_actions. There is a “set_TA_state” method available, and this can be used. However, one then needs to know the number of TA states. A “set_TA_action” method would be simpler to use, and could potentially be implemented by using the “set_TA_state” to set the TA state either in N (exclude) or N+1 (include).

Furthermore, it would be great if a “set_weight” method could be included so it would be possible to manually explore the influence on individual weights.

This issue is also related to Issue #43.

TMU learning faulty, shown in https://github.com/bimalb58/trec_exp

TMU learning faulty, shown in https://github.com/bimalb58/trec_exp

Testing error does not increase:

94.24 17.20 0.14 7.49 0.41 1
95.45 17.60 0.15 4.85 0.41 1
97.27 17.20 0.14 4.44 0.41 1
97.49 17.00 0.14 4.22 0.41 1
97.82 17.00 0.14 4.15 0.41 1
97.71 17.20 0.14 4.09 0.41 1
98.06 17.00 0.14 3.99 0.41 1
98.09 16.80 0.14 3.84 0.41 1
98.26 17.00 0.14 3.85 0.41 1
97.96 17.00 0.14 3.75 0.41 1
98.07 17.20 0.14 3.80 0.41 1
98.37 17.00 0.14 3.84 0.41 1
98.44 16.60 0.14 3.85 0.41 1
98.31 17.00 0.14 3.67 0.41 1
98.48 17.00 0.14 3.70 0.41 1
98.17 17.20 0.14 3.72 0.41 1
98.29 17.20 0.14 3.68 0.41 1
98.46 17.00 0.14 3.66 0.41 1
98.44 17.00 0.14 3.75 0.41 1
98.48 17.00 0.14 3.75 0.41 1
98.46 17.00 0.14 3.66 0.41 1
98.66 16.60 0.14 3.71 0.41 1
98.50 17.00 0.14 3.67 0.41 1
98.55 17.00 0.14 3.68 0.41 1
98.55 17.00 0.14 3.71 0.41 1
98.50 17.00 0.14 3.70 0.41 1
98.59 16.80 0.14 3.68 0.41 1
98.70 16.60 0.14 3.63 0.41 1
98.61 17.00 0.14 3.63 0.41 1
98.61 17.00 0.14 3.63 0.41 1
98.57 17.00 0.14 3.59 0.41 1
98.59 17.00 0.14 3.55 0.41 1
98.77 16.40 0.14 3.64 0.41 1
98.64 16.80 0.14 3.69 0.41 1
98.70 16.80 0.14 3.63 0.41 1
98.61 94.40 0.95 3.60 0.42 1

and then you get the following error:

Traceback (most recent call last):
File "/data/trec_exp/./trec.py", line 169, in
result = 100*(tm.predict(X_train) == Y_train).mean()
File "/usr/local/lib/python3.10/dist-packages/tmu/models/classification/vanilla_classifier.py", line 430, in predict
class_sums = np.array([
File "/usr/local/lib/python3.10/dist-packages/tmu/models/classification/vanilla_classifier.py", line 431, in
self.predict_compute_class_sums(
File "/usr/local/lib/python3.10/dist-packages/tmu/models/classification/vanilla_classifier.py", line 465, in predict_compute_class_sums
self.clause_banks[ith_class].calculate_clause_outputs_predict(encoded_X_test, ith_sample)
File "/usr/local/lib/python3.10/dist-packages/tmu/clause_bank/clause_bank_cuda.py", line 197, in calculate_clause_outputs_predict
self.cuda_ctx.synchronize()
pycuda._driver.LogicError: cuCtxSynchronize failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuModuleUnload failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered
PyCUDA WARNING: a clean-up operation failed (dead context maybe?)
cuMemFree failed: an illegal memory access was encountered

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.