hyperdimensional-computing / torchhd

Torchhd is a Python library for Hyperdimensional Computing and Vector Symbolic Architectures
https://torchhd.readthedocs.io
MIT License
248 stars 25 forks source link

FPE is not working after adding new check #147

Closed denkle closed 1 year ago

denkle commented 1 year ago

@mikeheddes, there are new check lines in the current version of FPE in embeddings:

        if dtype not in self.vsa_tensor.supported_dtypes:
            raise ValueError(f"dtype {dtype} not supported by {vsa}")

When evaluating cell 7 in the example notebook:

# Creat the initial object
fpe = torchhd.embeddings.FractionalPower(
    1, dimensions, distribution=kernel_shape, bandwidth=1.0, vsa=vsa_model
)

There is an error - --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /var/folders/hn/c7_j6kg54ss3zc20yjgzs2_80000gp/T/ipykernel_8346/972102016.py in 3 # Creat the initial object 4 fpe = torchhd.embeddings.FractionalPower( ----> 5 1, dimensions, distribution=kernel_shape, bandwidth=1.0, vsa=vsa_model 6 ) 7 fpes = fpe(values.view(-1, 1))

~/Downloads/torchhd-main/torchhd/embeddings.py in init(self, in_features, out_features, distribution, bandwidth, vsa, device, dtype, requires_grad) 1035 1036 if dtype not in self.vsa_tensor.supported_dtypes: -> 1037 raise ValueError(f"dtype {dtype} not supported by {vsa}") 1038 1039 # If the distribution is a string use the presets in predefined_kernels

ValueError: dtype None not supported by FHRR

So look like dtype is not behaving as expected because the class description says "dtype (torch.dtype, optional): the desired data type of returned tensor. Default: if None uses default of VSATensor.". Could you please take a look because I am getting lost at this point with dtype/device peculiarities.

P.S. The credit for identifying an issue goes to Kenny Schlegel.

mikeheddes commented 1 year ago

Apologies for the error. I'm fixing it right away. Thank you for reporting it Kenny!