allanj/pytorch_neural_crf

question about parameter

JingliSHI0206 opened this issue · 2 comments

currentTagScores = torch.gather(all_scores, 3, tags.view(batchSize, sentLength, 1, 1).expand(batchSize, sentLength, self.label_size, 1)).view(batchSize, -1, self.label_size)
(code from linear_crf_inference.py)

cannot figure out why it is 3 in gather function? all_scores is a 3d tensor, the max dim should be 2.
thank you

all_score is actually 4d tensor with size : (batch, seq_len, label_size, label_size)
https://github.com/allanj/pytorch_lstmcrf/blob/master/model/module/linear_crf_inferencer.py#L175

for why is it 4d tensor: check out how we calculate the score:
https://github.com/allanj/pytorch_lstmcrf/blob/master/model/module/linear_crf_inferencer.py#L196-L208

Feel free to ask more questions if you are confused

all_score is actually 4d tensor with size : (batch, seq_len, label_size, label_size)
https://github.com/allanj/pytorch_lstmcrf/blob/master/model/module/linear_crf_inferencer.py#L175

for why is it 4d tensor: check out how we calculate the score:
https://github.com/allanj/pytorch_lstmcrf/blob/master/model/module/linear_crf_inferencer.py#L196-L208

Feel free to ask more questions if you are confused

many thanks for the prompt reply.