uma-pi1 / kge

LibKGE - A knowledge graph embedding library for reproducible research
MIT License
776 stars 124 forks source link

When Evaluating on valid data,I encounter TypeError: expected dtype object, got 'numpy.dtype[int32]' #198

Closed RainbowCatSzy closed 3 years ago

RainbowCatSzy commented 3 years ago

Evaluating on valid data (epoch 5)... Traceback (most recent call last): File "/kge/kge/cli.py", line 285, in main job.run() File "/kge/kge/job/job.py", line 159, in run result = self._run() File "/kge/kge/job/train.py", line 222, in _run trace_entry = self.valid_job.run() File "/kge/kge/job/job.py", line 159, in run result = self._run() File "/kge/kge/job/eval.py", line 67, in _run self._evaluate() File "/.conda/envs/machine/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/kge/kge/job/eval_entity_ranking.py", line 140, in _evaluate for batch_number, batch_coords in enumerate(self.loader): File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next data = self._next_data() File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch return self.collate_fn(data) File "/kge/kge/job/eval_entity_ranking.py", line 83, in _collate self.dataset.index(f"{split}_po_to_s"), File "/kge/kge/job/util.py", line 19, in get_sp_po_coords_from_spo_batch sp_coords = sp_index.get_all(batch[:, [0, 1]]) File "/kge/kge/indexing.py", line 151, in get_all self._values.numpy(), self._values_offset.numpy() TypeError: expected dtype object, got 'numpy.dtype[int32]'

rufex2001 commented 3 years ago

Hi, could you provide more context? Are you using KvsAll training? A custom model you made? Or are all settings straight from LibKGE? What are those settings? It seems you are using numpy somewhere.

On Tue, 27 Apr 2021, 03:42 RainbowRr, @.***> wrote:

Evaluating on valid data (epoch 5)... Traceback (most recent call last): File "/kge/kge/cli.py", line 285, in main job.run() File "/kge/kge/job/job.py", line 159, in run result = self._run() File "/kge/kge/job/train.py", line 222, in _run trace_entry = self.valid_job.run() File "/kge/kge/job/job.py", line 159, in run result = self._run() File "/kge/kge/job/eval.py", line 67, in _run self._evaluate() File "/.conda/envs/machine/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, *kwargs) File "/kge/kge/job/eval_entity_ranking.py", line 140, in _evaluate for batch_number, batch_coords in enumerate(self.loader): File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next* data = self._next_data() File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 475, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/.conda/envs/machine/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch return self.collate_fn(data) File "/kge/kge/job/eval_entity_ranking.py", line 83, in _collate self.dataset.index(f"{split}_po_to_s"), File "/kge/kge/job/util.py", line 19, in get_sp_po_coords_from_spo_batch sp_coords = sp_index.get_all(batch[:, [0, 1]]) File "/kge/kge/indexing.py", line 151, in get_all self._values.numpy(), self._values_offset.numpy() TypeError: expected dtype object, got 'numpy.dtype[int32]'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uma-pi1/kge/issues/198, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEWXZAEMUO3B2I7DRI7CG3TKYJBHANCNFSM43UAONTQ .

AdrianKs commented 3 years ago

This could probably occur due to our update in the filtering in evaluation. There we introduced numba and therefore convert to numpy first. Could you please share your configuration file, so we can debug this.

imohitmayank commented 3 years ago

Getting the same error message on running the toy example (following the readme file) kge start examples/toy-complex-train.yaml --job.device cpu

rgemulla commented 3 years ago

Does the issue still arise if you first delete all *.pckl files under data/toy?

imohitmayank commented 3 years ago

Yes, tried again after removing all *.pckl file, getting the same error. (btw the traceback is same)

AdrianKs commented 3 years ago

I can not reporduce this bug. Are you using Linux or Windows? Are you using the dependency versions specified in the setup? In particular numba==0.50.*?

RainbowCatSzy commented 3 years ago

I can not reporduce this bug. Are you using Linux or Windows? Are you using the dependency versions specified in the setup? In particular numba==0.50.*?

hi, I am using the complex.yaml and distmult.yaml for fb15k dataset provided in read me

imohitmayank commented 3 years ago

I can not reporduce this bug. Are you using Linux or Windows? Are you using the dependency versions specified in the setup? In particular numba==0.50.*?

I am using Ubuntu, python 3.7.5 with numba-0.50.1. That said, I will re-download the repo and try again. Will report back.

AdrianKs commented 3 years ago

Just to make sure, I also reinstalled. Works all fine for me. ONly thing different is that I have python 3.8.5 installed. Can you try if upgrading to python 3.8 helps.

rgemulla commented 3 years ago

Perhaps related to https://github.com/numba/numba/issues/6041

This bug seems to occur with numpy 1.20. Which version of numpy do you use? If that's the issue, we may want to constrain the numpy version as well fo rnow (I am using 1.19.1).

MatthewGleeson commented 3 years ago

I ran into the same problem when training ComplEx on a custom dataset. Downgrading to numpy=1.19.1 fixed the problem for me!

rgemulla commented 3 years ago

Thanks @MatthewGleeson!

@AdrianKs It's probably best if we upgrade LibKGE's numba version instead of forcing a downgrade of numpy.

AdrianKs commented 3 years ago

upgraded to newest numba version (0.53.1) in 53303ca . everything seems to work with the new version.