kmkurn / pytorch-crf

(Linear-chain) Conditional random field in PyTorch.

Home Page:https://pytorch-crf.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

代码错误

Wsl-hfut-nwpu opened this issue · comments

我认为你的代码有问题,当初始化的时候传入的参数batch_first=True之后,在后面的代码中并未考虑batch翻转的情况,因为seq_length, batch_size = tags.shape对batch在第二个维度进行了限制。

Hi, I don't know Mandarin (I assume that's the language you wrote, sorry if I'm wrong) so I can't understand your text. Can you write it in English?

Hi, I don't know Mandarin (I assume that's the language you wrote, sorry if I'm wrong) so I can't understand your text. Can you write it in English?

Hi~ Let me translate for you, he spoke in Chinese.
What he means:
"I think there is an error with your code. When the parameter 'batch_first=True' is passed during initialization, the subsequent code doesn't consider the batch flipping, because 'seq_length, batch_size=tags.shape' limits batch in the second dimention."
Hope it will help you understand~

@Emperorizzis Thanks for translating!

@Wsl-hfut-nwpu Are you referring to this line?

seq_length, batch_size = tags.shape
That method is only called after the batch and seq length dimension is swapped. If you think otherwise, can you give a minimal example that reproduces the error?