New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loss function #21
Comments
It's the mean of all the losses. So the sum divided by the number of elements. You will see reduction = 'mean' in losses.py |
Thank you for your answer. I also have a question. What does N stand for in equation (7)
…------------------ 原始邮件 ------------------
发件人: "yassouali/CCT" <notifications@github.com>;
发送时间: 2020年10月18日(星期天) 晚上6:24
收件人: "yassouali/CCT"<CCT@noreply.github.com>;
抄送: "Clown"<1572112413@qq.com>;"Author"<author@noreply.github.com>;
主题: Re: [yassouali/CCT] Loss function (#21)
It's the mean of all the losses. So the sum divided by the number of elements. You will see reduction = 'mean' in losses.py
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I am very confused about how loss functions are calculated: per pixel, per image, all images at once? The general formula for MSE can also be found here In the paper, I think it's the number of outputs generated for all the input images (=number of images * number of aux. decoders). (Correct me if I am wrong, @yassouali ) |
Hi @yrcrcy N is the pixels of the image (N = H x W). When computing the loss, we average over both the pixels of a given image, and the images on the batch (so mean over dim = 0 for the batch size, and mean over Dim = 2 and 3 for height and width). You can only average over the batch ( |
In the calculation formula of supervised loss and unsupervised loss, are |Qu| and |Ql| also batch-size averages?
…------------------ 原始邮件 ------------------
发件人: "yassouali/CCT" <notifications@github.com>;
发送时间: 2020年10月19日(星期一) 晚上11:42
收件人: "yassouali/CCT"<CCT@noreply.github.com>;
抄送: "Clown"<1572112413@qq.com>;"Mention"<mention@noreply.github.com>;
主题: Re: [yassouali/CCT] Loss function (#21)
Hi @yrcrcy
Thank you for your interest, and thanks to @SuzannaLin for answering the questions.
N is the pixels of the image (N = H x W). When computing the loss, we average over both the pixels of a given image, and the images on the batch (so mean over dim = 0 for the batch size, and mean over Dim = 2 and 3 for height and width).
You can only average over the batch (batch-mean), or even summing over both the batch and pixels, but in this case the LR needs to be reduced to avoid diverging during training. You can see the averaging as a way of having a stable loss.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Yes, @yrcrcy that is correct. @SuzannaLin For the mse loss, the mean is over all elements of the tensor, so a mean over both batches and pixels (as detailed below for the usage of reduction = "mean"). |
Thank you for your contribution. I want to know what the |Dl| and |Du| in your cross-entropy loss function formula and semi-supervised loss function formula represent, thank you for your answer.
The text was updated successfully, but these errors were encountered: