liuhu-bigeye / enctc.crnn

Project for Connectionist Temporal Classification with Maximum Entropy Regularization.
MIT License
143 stars 40 forks source link

seg_ctc_ent_loss_log()函数的blank变量没有使用? #17

Open fangshuiyun opened 11 months ago

fangshuiyun commented 11 months ago

def seg_ctc_ent_loss_log(pred, pred_len, token, token_len, uniform_mask, blank=0): 您好!我看到blank变量并没有在函数内部提及,而且我所设定的blank!=0,这是怎么回事?还是说不建议使用seg_ctc_ent_loss_log?使用ctc_ent_loss_log比较好,ctc_ent_loss_log的blank变量在函数内部有提及,可以改! 如能有回复,非常感谢!!!

My-captain commented 7 months ago

我觉得这里是有问题的,我是这样修改的,你可以参考

token_with_blank = torch.nn.functional.pad(target.unsqueeze(1), pad=(0, 1, 1, 0), mode='constant', value=blank).flatten()[1:]
token_with_blank = token_with_blank.contiguous()
length = token_with_blank.shape[0]
ctc_log_prob = ctc_log_prob[:, token_with_blank]