mana-ysh / knowledge-graph-embeddings

Implementations of Embedding-based methods for Knowledge Base Completion tasks
Apache License 2.0
257 stars 63 forks source link

HolE implementation seems to ignore labels #11

Open svjan5 opened 5 years ago

svjan5 commented 5 years ago

Hi, I couldn't understand why are we ignoring label information in hole.py by taking np.abs during softplus operation defined in math_utils.py (link).

Thanks in advance

mana-ysh commented 5 years ago

Hi @svjan5 My softplus function has max(0, x) term, so it doesn’t ignore the label, I think.

In [23]: def softplus(x): return np.maximum(0, x)+np.log(1+np.exp(-np.abs(-x)))
In [35]: softplus(1)
Out[35]: 1.3132616875182228

In [36]: softplus(-1)
Out[36]: 0.31326168751822286

Since naive softplus function often occurs overflow warning, my function has this form.

svjan5 commented 5 years ago

Hi, Thank you for the reply. I was matching your HolE implementation with the original implementation from M. Nickel (scikit-kge). There is some difference in the computation of score function (yours|his). Also he doesn't include max(0,x) while computing loss (link).

Can you please clarify?