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

crf调用报错 #44

Open
RileyShe opened this issue Mar 23, 2022 · 0 comments
Open

crf调用报错 #44

RileyShe opened this issue Mar 23, 2022 · 0 comments

Comments

@RileyShe
Copy link

"crf.py", line 177, in _compute_score
score = self.start_transitions[tags[0]]
IndexError: index -100 is out of bounds for dimension 0 with size 5

上面是报错信息,但是-100 是label_id的padding值哦,理论上没啥问题吧。

        score = self.start_transitions[tags[0]]
        score += emissions[0, torch.arange(batch_size), tags[0]]

        for i in range(1, seq_length):
            # Transition score to next tag, only added if next timestep is valid (mask == 1)
            # shape: (batch_size,)
            score += self.transitions[tags[i - 1], tags[i]] * mask[i]

            # Emission score for next tag, only added if next timestep is valid (mask == 1)
            # shape: (batch_size,)
            score += emissions[i, torch.arange(batch_size), tags[i]] * mask[i]

这部分代码中,为啥tags[0] 先不需要*mask[0] 再计算得分??

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