How should this loss function be written? #19021
Replies: 1 comment 3 replies
-
I don't fully understand the context but I do have a suggestion. The final loss calculation should only be done using the predictions and labels. It purely depends on the decoder's output and the labels. It is independent of the inputs you give to the encoder/decoder. So, you could try calculating the cross-entropy loss between prediction-label pairs individually, the taking the mean/sum. Here's is a sample: def loss(predict1, predict2, label1, label2):
loss1 = cross_entropy(predict1, label1)
loss2 = cross_entropy(predict2, label2)
return (loss1 + loss2)/2 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
this is the model, it has two encoder and one decoder, call just for init, it not use in inference :
this is i create TrainState, if it has any issue, please tell me:
I don't know how to write loss_fn, it have two input and two label, it should like this:
encode1(input1) -> s1 -> decoder(s1) -> predict1 -> (predict1,label1)
encode2(input2) -> s2 -> decoder(s2) -> predict2 -> (predict2,label2)
How should this loss function be written? please give me a example, thanks.
Beta Was this translation helpful? Give feedback.
All reactions