eXascaleInfolab / ActiveLink

Deep active learning framework for link prediction in knowledge graph
24 stars 7 forks source link

Why indexing entities and relations from 0 is a bad idea? #5

Open t170815518 opened 4 years ago

t170815518 commented 4 years ago

Hi, I saw your code with comments like "starting from 0 is a bad idea". Why is that so? Based on my experience, starting from 1 will cause pretty many problems:

  1. TransE.cpp (mentioned by you) will have segmentation fault if starting from 1, which will be solved by starting from 0
  2. enumerate() starts from 0, however, some parts of the code doesn't handle it and causes KeyError
  3. I am not quite sure if the model.py can run successfully, because the embedding layer takes the input with the dimension of (number of entities/relations, ); but without (number of entities/relations+1, ), out-of-range problem will raise.
  4. For question 3., I tried "+1", but pred = x + self.b.expand_as(x) will give the error: RuntimeError: The expanded size of the tensor (14542) must match the existing size (14541) at non-singleton dimension 1. Target sizes: [128, 14542]. Tensor sizes: [14541] python-BaseException

Why indexing entities and relations from 0 is a bad idea?