11
votes
Accepted
Loss jumps abruptly when I decay the learning rate with Adam optimizer in PyTorch
I see no reason why decaying learning rates should create the kinds of jumps in losses that you are observing. It should "slow down" how quickly you "move", which in the case of a loss that otherwise ...
10
votes
Can the mean squared error be negative?
In general a cost function can be negative. The more negative, the better of course, because you are measuring a cost the objective is to minimise it.
A standard Mean Squared Error function cannot be ...
10
votes
Accepted
What loss function to use when labels are probabilities?
Actually, the cross-entropy loss function would be appropriate here, since it measures the "distance" between a distribution $q$ and the "true" distribution $p$.
You are right, ...
8
votes
Accepted
What is an objective function?
The "objective function" is the function that you want to minimise or maximise in your problem.
The expression "objective function" is used in several different contexts (e.g. machine learning or ...
8
votes
Accepted
In which cases is the categorical cross-entropy better than the mean squared error?
As a rule of thumb, mean squared error (MSE) is more appropriate for regression problems, that is, problems where the output is a numerical value (i.e. a floating-point number or, in general, a real ...
8
votes
Accepted
Why is the evidence equal to the KL divergence plus the loss?
In variational inference, the original objective is to minimize the Kullback-Leibler divergence between the variational distribution, $q(z \mid x)$, and the posterior, $p(z \mid x) = \frac{p(x, z)}{\...
8
votes
Accepted
What is the cost function of a transformer?
I took a look at the Tensor2Tensor's source code implementation, and it seems like the loss function is the cross-entropy between the predicted probability matrix $\|\text{sentence length}\| \times \|\...
7
votes
Accepted
How can we process the data from both the true distribution and the generator?
The Focus of This Question
"How can ... we process the data from the true distribution and the data from the generative model in the same iteration?
Analyzing the Foundational Publication
In the ...
7
votes
Accepted
Which function $(\hat{y} - y)^2$ or $(y - \hat{y})^2$ should I use to compute the gradient?
The derivative of $\mathcal{L_1}(y, x) = (\hat{y} - y)^2 = (f(x) - y)^2$ with respect to $\hat{y}$, where $f$ is the model and $\hat{y} = f(x)$ is the output of the model, is
\begin{align}
\frac{d}{...
7
votes
Which function $(\hat{y} - y)^2$ or $(y - \hat{y})^2$ should I use to compute the gradient?
The MSE can be defined as $(\hat{y} - y)^2$, which should be equivalent to $(y - \hat{y})^2$
They are not just "equivalent". It is actually the exact same function, with two different ways to write ...
7
votes
Accepted
What is the difference between a loss function and reward/penalty in Deep Reinforcement Learning?
1. Question: The difference between loss and reward/penalty
So I see both the loss function and the reward/penalty are the quantitative way of measuring the output/action and making the model to ...
6
votes
Accepted
What is the formula used to calculate the loss in the FaceNet model?
The loss function used is the triplet loss function.
Let me explain it part by part.
Notation
The $f^a_i$ means the anchor input image. The $f^p_i$ means the <...
6
votes
Accepted
In variational autoencoders, why do people use MSE for the loss?
If $p(x|z) \sim \mathcal{N}(f(z), I)$, then
\begin{align}
\log\ p(x|z)
&\sim \log\ \exp(-(x-f(z))^2) \\
&\sim -(x-f(z))^2 \\
&= -(x-\hat{x})^2,
\end{align}
where $\hat{x}$, the ...
6
votes
What is the reason we loop over epochs when training a neural network?
I am not expert on optimization, but I can share with you my knowledge of the topic.
I think that the source of your confusion is that you assumed that, after the first epoch, we have reached a local ...
6
votes
Accepted
What is the best way to combine or weight multiple losses with gradient descent?
This is an important subfield within multi-task learning, called gradient combination. Here is a list of about a dozen recent approaches: https://github.com/Manchery/awesome-multi-task-learning#loss--...
5
votes
Accepted
What are the major differences between cost, loss, error, fitness, utility, objective, criterion functions?
They are not all interchangeable. However, all these expressions are related to each other and to the concept of optimization. Some of them are synonymous, but keep in mind that these terms may not be ...
5
votes
Accepted
Why L2 loss is more commonly used in Neural Networks than other loss functions?
I'll cover both L2 regularized loss, as well as Mean-Squared Error (MSE):
MSE:
L2 loss is continuously-differentiable across any domain, unlike L1 loss. This makes training more stable and allows ...
4
votes
Accepted
Can gradient descent training be used for non-smooth loss functions?
Gradient descent and stochastic gradient descent can be applied to any differentiable loss function irrespective of whether it is convex or non-convex. The "differentiable" requirement ensures that ...
4
votes
Accepted
Could error surface shape be useful to detect which local minima is better for generalization?
In general I agree with @nbro answer, nevertheless sticking strictly to this specific question I'd like to share some speculations:
what the author of the question provides us with is the Loss ...
4
votes
Accepted
Why is the Jensen-Shannon divergence preferred over the KL divergence in measuring the performance of a generative network?
Lets start with question 1) how does JS-divergence handles zeros?
by definition:
\begin{align}
D_{JS}(p||q) &= \frac{1}{2}[D_{KL}(p||\frac{p+q}{2}) + D_{KL}(q||\frac{p+q}{2})] \\
&= \frac{...
4
votes
Accepted
Is there a reason to choose regular momentum over Nesterov momentum for neural networks?
The book Deep Learning by Goodfellow, Bengio, and Courville says (Sec 8.3.3, p 292 in my copy) states that
Unfortunately, in the stochastic gradient case, Nesterov momentum does not improve the ...
4
votes
Loss function for choosing a subset of objects
The choice of the loss function depends primarily on the type of task you're tackling: classification or regression. Your problem is clearly a classification one since you have classes to which a ...
4
votes
Accepted
Why is the mean used to compute the expectation in the GAN loss?
It seems your question is concerned with how an empirical mean works.
It is indeed true that, if all $x^{(i)}$ are independent identically distributed realisations of a random variable $X$, then $\...
4
votes
Accepted
Where is the mistake in my derivation of the GAN loss function?
I guess the issue is you lost track of where the samples came from and since you requested a math explanation I'll try to go step by step using my notation and without checking other material to avoid ...
3
votes
Accepted
Why is the "square error function" sometimes defined with the constant 1/2 and sometimes with the constant 1/m?
The first variation is named "$E_{total}$". It contains a sum which is not very well-specified (has no index, no limits). Rewriting it using the notation of the second variation would lead to:
$$E_{...
3
votes
Accepted
How to obtain a formula for loss, when given an iterative update rule in gradient descent?
You can find an implementation of the REINFORCE algorithm (as defined in your question) in PyTorch at the following URL: https://github.com/JamesChuanggg/pytorch-REINFORCE/. First of all, I would like ...
3
votes
Accepted
How can the sum of squared errors have negative gradient if it's defined as the squared of the error?
If $t^i - o^i$ is negative, doesn't the power of 2 eliminate any negative result?
In the loss function, yes that is correct, and is what you want - a measurement that gets higher due to any ...
3
votes
How can we process the data from both the true distribution and the generator?
Let's start at the beginning. GANs are models that can learn to create data that is similar to the data that we give them.
When training a generative model other than a GAN, the easiest loss function ...
3
votes
Accepted
Analysis of Training Loss and Validation Loss Graph
Simply model 1 is a better fit compared to model 2.
Graph for model 1
We notice that the training loss and validation loss ...
3
votes
Accepted
Is it possible with stochastic gradient descent for the error to increase?
Yes. Not only that, but error is highly noisy, prone to big spikes and sometimes quite long period of increase before decrease again or stabilize. Often it's even impossible to understand error plot ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
objective-functions × 267neural-networks × 75
deep-learning × 60
machine-learning × 43
reinforcement-learning × 30
gradient-descent × 26
convolutional-neural-networks × 20
classification × 19
generative-adversarial-networks × 19
optimization × 19
backpropagation × 17
pytorch × 16
training × 15
papers × 13
math × 13
loss × 13
keras × 12
comparison × 11
tensorflow × 11
activation-functions × 10
image-segmentation × 10
cross-entropy × 10
deep-rl × 9
dqn × 9
natural-language-processing × 7