Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

splits cross entropy can be further optimized #62

Open
ReactiveCJ opened this issue Jul 13, 2018 · 2 comments
Open

splits cross entropy can be further optimized #62

ReactiveCJ opened this issue Jul 13, 2018 · 2 comments

Comments

@ReactiveCJ
Copy link

for idx in range(self.nsplits):

As the word in tail, the probability of this word is p(C) * p(x=target|C), then the entropy is target * log(p(C) * p(x=target|C) = target * log(P(C)) + target + log(p(x=target|C)。

We can just add the cross entropy on the head include tombstones, then compute cross entropy on each tail, so it is no need pass head_entropy below.

@ReactiveCJ
Copy link
Author

At the line 166 of splitcross.py "entropy = -(head_entropy + tail_entropy)", we need not add head_entropy cause it have been added in logprob "results.append(head_entropy.view(-1, 1) + tail_entropy)"

@octavian-ganea
Copy link

I replaced this complicated SplitCrossEntropyLoss by the pytorch cross entropy loss which produces the same results and seems to be only slightly slower.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants