且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在损失函数中使用模型输入?

更新时间:2023-12-02 19:58:46

使用lambda函数是否起作用? ( https://www.w3schools.com/python/python_lambda.asp )

Did using lambda function work? (https://www.w3schools.com/python/python_lambda.asp)

loss = lambda x1, x2: rnnt_loss(x1, x2, acts, labels, input_lengths,
                                label_lengths, blank_label=0)

这样,您的损失函数应该是接受参数x1x2的函数,但是rnnt_loss也可以知道actslabelsinput_lengthslabel_lengthsblank_label

In this way your loss function should be a function accepting parameters x1 and x2, but rnnt_loss can also be aware of acts, labels, input_lengths, label_lengths and blank_label