kmkurn / pytorch-crf

(Linear-chain) Conditional random field in PyTorch.
https://pytorch-crf.readthedocs.io
MIT License
935 stars 151 forks source link

A question about the initialization #73

Closed speedcell4 closed 2 years ago

speedcell4 commented 3 years ago

Hi~ Why do you initialize the transition matrix in this way? Is it a theoretically optimal initialization method? Or it's just an empirical method?

https://github.com/kmkurn/pytorch-crf/blob/4cd79bc8af55fb0f34a2a39b2e38f0e71c208fd4/torchcrf/__init__.py#L50-L58

speedcell4 commented 3 years ago

I have seen some repositories initialize it as nn.init.zeros_, not sure which one is better

kmkurn commented 3 years ago

Hi, there's no particular reason, to be honest. You can experiment with it yourself to see which one works best in your case.