Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity Relatedness Function #1

Open
petarR opened this issue Jul 29, 2019 · 0 comments
Open

Entity Relatedness Function #1

petarR opened this issue Jul 29, 2019 · 0 comments

Comments

@petarR
Copy link

petarR commented Jul 29, 2019

I think there might be a mistake how the relatedness is calculated. In entityRelatedness_model.py line 62 is calculating cosine or euclidian distance between the entities, whereas it needs to be calculating the probability of the related entity appearing after the main entity, which should be done with the softmax function.

The distance function could be replaced with:

def get_relatedness_for(sourceEntity, targetEntity, model, method="skip"):
    iprob=0
    if method=="skip":
        # skip gram
        iprob = 1.0 / (1.0 + np.exp(-np.dot(model.syn1neg[targetEntity.index].T, model.syn0[sourceEntity.index])))
    if method =="cbow":
        #cbow
        iprob = 1.0 / (1.0 + np.exp(-np.dot(model.syn0[targetEntity.index].T, model.syn1neg[sourceEntity.index])))
    return str(iprob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant