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

Type-based NCE #7

Closed
SRL94 opened this issue Jul 13, 2021 · 3 comments
Closed

Type-based NCE #7

SRL94 opened this issue Jul 13, 2021 · 3 comments

Comments

@SRL94
Copy link

SRL94 commented Jul 13, 2021

Hi,

I found you used type-based noise-constrained estimation (NCE) for negative sampling, which is very interesting. Could you please tell me which part of your code is for the NCE?

Best regards
Sirui

@guolingbing
Copy link
Collaborator

In fact, we create two different weight matrices for entity prediction and relation prediction, respectively. When the target is a relation, we only need to call the standard NCE function tf.nn.nce_loss with the corresponding relation weight matrix as input.

@SRL94
Copy link
Author

SRL94 commented Jul 15, 2021

Thanks for the explaination but I am still confused about the NCE-based negative sampling. My understanding is: in the entity prediction, the input is the entity embedding matrix and the tf.nn.nce_loss output is the negative samples, is it right?

@guolingbing
Copy link
Collaborator

Almost right. tf.nn.nce_loss is a high-level API that computes (include negative sampling) and returns the loss. If you want to customize the sampling algorithm, I suggest you have a look at log_uniform_candidate_sampler. tf.nn.nce_loss has such an augment sampled_values to receive sampled entities:

a tuple of (sampled_candidates, true_expected_count, sampled_expected_count) returned by a *_candidate_sampler function.

Thanks for your attention to our work.

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

2 participants