Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [loss-functions]

For questions related to the concept of loss (or cost) function in the context of machine learning.

Filter by
Sorted by
Tagged with
16
votes
3answers
22k views

Understanding GAN loss function

I'm struggling to understand the GAN loss function as provided in Understanding Generative Adversarial Networks (a blog post written by Daniel Seita). In the standard cross-entropy loss, we have an ...
9
votes
1answer
3k views

Loss jumps abruptly when I decay the learning rate with Adam optimizer in PyTorch

I'm training an auto-encoder network with Adam optimizer (with amsgrad=True) and ...
5
votes
1answer
284 views

What loss function to use when labels are probabilities?

What loss function is most appropriate when training a model with target values that are probabilities? For example, I have a 3-output model. I want to train it with a feature vector $x=[x_1, x_2, \...
5
votes
1answer
78 views

What is the formula used to calculate the loss in the FaceNet model?

The FaceNet model returns the loss of the predictions and ground-truth classes. How is this loss calculated?
5
votes
1answer
164 views

What's the advantage of log_softmax over softmax?

Previously I have learned that the softmax as the output layer coupled with the log-likelihood cost function (the same as the ...
4
votes
3answers
193 views

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 equal to $(y - \hat{y})^2$, but I think their derivative is different, so I am confused of what derivative will I use for computing my ...
4
votes
1answer
46 views

Why does the binary cross-entropy work better than categorical cross-entropy in a multi-class single label problem?

I was just doing a simple NN example with the fashion MNIST dataset, where I was getting 97% accuracy, when I noticed that I was using Binary cross-entropy instead of categorical cross-entropy by ...
4
votes
1answer
52 views

How to define a loss function for a classifier where the confusion between some classes is more important than the confusion between others?

I have a dataset of images belonging to $N$ classes, $A_1, A_2...A_n,B_1,B_2...B_m$ and I want to train a CNN to classify them. The classes can be considered as subclasses of two broader classes $A$ ...
3
votes
2answers
60 views

Could error surface shape be useful to detect which local minima is better for generalization?

The following plot shows error function output based on system weights. Two equal local minima are shown in green pointers. Note that the red dots are not related to the question. Does the right one ...
3
votes
1answer
141 views

What's the difference between RMSE and Euclidean distance, and when to use a custom loss? [on hold]

I'm searching for a loss function that fits my project. Actually, I have two questions, but they are in the same direction. I take a look at the definition of the root mean squared error (RMSE) and ...
3
votes
1answer
124 views

Alphazero policy head loss not decreasing

I am now working on training an alphazero player for a board game. The implementation of board game is mine, MCTS for alphazero was taken elsewhere. Due to complexity of the game, it takes a much ...
3
votes
1answer
86 views

How is equation 8 derived in the paper “Self-critical sequence training for image captioning”?

In the paper "Self-critical sequence training for image captioning", on page 3, they define the loss function (of the parameters $\theta$) of an image captioning system as the negative expected reward ...
3
votes
1answer
33 views

Why is Jensen-Shannon divergence preferred over Kullback-Leibler divergence in measuring the performance of a generative network?

I have read articles on how Jensen-Shannon divergence is preferred over Kullback-Leibler in measuring how good a distribution mapping is learned in a generative network because of the fact that JS-...
3
votes
1answer
60 views

Advantages of Kullback-Leibler over L1/L2?

I've recently encounter different articles that are recommending to use KL instead of L1/L2 norm when trying to minimize a probability distribution. But none of the articles are giving a clear ...
3
votes
1answer
41 views

Decreasing Loss, Constant Accuracy

Problem Statement I've built a classifier to classify a dataset consisting of n samples and four classes of data. To this end, I've used pretrained VGG-19, pretrained Alexnet and even lenet (with ...
3
votes
1answer
304 views

Dice loss gives binary output whereas binary crossentropy produces probability output map

On recommendation of Kanak on stackoverflow I am posting this question here: Currently I am experimenting with various loss functions and optimizers for my binary image segmentation problem. The loss ...
3
votes
0answers
40 views

When to use RMSE as opposed to MSE and vice versa?

I understand that RMSE is just the square root of MSE. Generally, as far as I have seen, people seem to use MSE as a loss function and RMSE for evaluation purposes, since it exactly gives you the ...
3
votes
1answer
68 views

Should the input to the negative log likelihood loss function be probabilities?

I am trying to train a supervised model where the output from the model is output of a linear function $WX + b$. Kindly note that I'm not using any softmax or $\log$ softmax on the result of the ...
2
votes
2answers
2k views

Can the mean squared error be negative?

I'm new to machine learning. I was watching a prof. Ng's video about gradient descent from the machine learning course. It said that we want our cost function (in this case, the mean squared error) to ...
2
votes
2answers
60 views

What are the major differences between cost, loss, error, fitness, utility, objective, criterion functions?

I find the terms cost, loss, error, fitness, utility, objective, criterion functions to be interchangeable, but any kind of minor difference explained is appreciated.
2
votes
1answer
929 views

Why is the hyperbolic tangent with MSE better than the sigmoid with cross-entropy?

Usually, in binary classification problems, we use sigmoid as the activation function of the last layer plus the binary cross-entropy as cost function. However, I have already experienced (more than ...
2
votes
1answer
48 views

When and how to use a mix of loss functions for back-propagation?

I am trying to understand the best loss function to be used with a convolutional neural network. I came to know that we can mix two loss functions. Can any body share in what case was it done and how?
2
votes
1answer
57 views

Which loss function should I use for binary classification?

I plan to create a neural network using Python, Keras and TensorFlow. All the tutorials I have seen so far are concerned with image recognition. However, the goal of my program would be to take in 10+ ...
2
votes
2answers
67 views

How do we get the true value in the prediction objective in reinforcement learning?

In the book "Reinforcement Learning: An Introduction" (2018) Sutton and Barto define the prediction objective ($\overline{VE}$) as follows (page 199): $$\overline{VE}\doteq\sum_{s\epsilon S} \mu(s)[v_{...
2
votes
1answer
385 views

Gradient of hinge loss function

With reference to the research paper entitled Sentiment Embeddings with Applications to Sentiment Analysis, I am trying to implement its sentiment ranking model in Python for which I am required to ...
2
votes
0answers
40 views

How to implement loss function of H-GAN model

I was trying to implement the loss function of H-GAN. Here is my code . But it seem somethings wrong, maybe is recognition loss on z (EQ 9). I used the EQ 5 on MISO to calculate it. Here is my code: ...
2
votes
1answer
42 views

when should I create a custom loss function?

Hi I'm using neural network to solve a multi regression problem. I'm trying to predict continuous values, to be more specific I'm making a tracking algorithm to track the position of an Object, I'm ...
2
votes
0answers
140 views

Why the loss keep increasing during training?

I'm trying to use TensorFlow and this how I compute the loss ...
2
votes
0answers
40 views

CNN clasification model loss stuck at same value

I have CNN model to classify 2 classes. (Yes or No) I use categorical_crossentropy loss and softmax activation at the end. For input I use image with all 3 channels, for output I use One hot encoded ...
2
votes
0answers
34 views

Which loss functions for transforming a density function to another density function?

I am looking at a problem which can be distilled as follows: I have a phenomenon which can be modeled as a probability density function which is "messy" in that it sums to unity over its support but ...
2
votes
0answers
34 views

Should I use the hyperbolic distance loss in the case of Poincarè Disk Model?

I trained a neural network which makes a regression to a Poincarè Disk Model with radius $r = 1$. I want to optimize using the hyperbolic distance $$ \operatorname{arcosh} \left( 1 + \frac{2|pq|^2|...
2
votes
1answer
60 views

Comparing and studying Loss Functions

I have a Deep Feedforward Neural Network $F: W \times \mathbb{R}^d \rightarrow \mathbb{R}^k$ (where $W$ is the space of the weights) with $L$ hidden layers, $m$ neurones per layer and ReLu activation. ...
2
votes
0answers
217 views

Extend the loss function from the single action to the n-action case per time step

My question concerns a side question (which was not answered) asked here: Policy gradients for multiple continuous actions I am trying to implement a simple policy gradient algorithm for a discrete ...
2
votes
2answers
89 views

Why is MSE used over other quadratic loss functions?

So I was wondering, why I have only encountered square loss function also known as MSE. The only nice property of MSE I am so far aware of is its convex nature. But then all equations of the form $x^{...
1
vote
3answers
57 views

How to stop DQN Q function from increasing during learning?

Following the DQN algorithm with experience replay: We calculate the $loss=(Q(s,a)-(r+Q(s+1,a)))^2$. Assume I have positive but changing rewards. Meaning, $r>0$. Thus, since the rewards are ...
1
vote
1answer
66 views

How to obtain a formula for loss, when given an iterative update rule in gradient descent?

From the reinforcement learning book section 13.3: Using pytorch, I need to calculate a loss, and then the gradient is calculated internally. How to obtain the loss from equations which are stated ...
1
vote
1answer
27 views

How is the percentage or the probablity calculated using Loss function in Facenet Model?

This question is related to What is the formula used to calculate the accuracy in the FaceNet model? . I know how loss is calculated in the FaceNet model , but how the loss function is used to ...
1
vote
1answer
33 views

Why is image classification tasks are dominated by minimizing cost function instead of maximizing ones?

I was watching a video of policy gradient by Andrej Karpathy at 10:00 there shows an equation for supervised learning for image classification. $max\sum _{i}log \:p(y_i|x_i)$ I have worked with ...
1
vote
1answer
30 views

What loss function is appropriate for finding “points of interest” in a array of x,y inputs

I am looking into whether a neural network is appropriate to detect "points of interest" (POI) in a set of tuples (say length, and some sensor value). A POI is essentially a quick change in the value ...
1
vote
1answer
48 views

What is the best loss function for convolution neural network and autoencoder?

What is the best choice for loss function in Convolution Neural Network and in Autoencoder in particular - and why? I understand that the MSE is probably not the best choice, because little ...
1
vote
1answer
42 views

Train and Test Accuracy of GRU network not increasing after 2nd epoch

So I´m currently implementing my first neural network using GRUs as a model and Keras as an implementation since it´s pretty highlevel. My problem is about the classification of 8 hour long timeseries ...
1
vote
1answer
30 views

Understanding how the loss was calculated for the SQuAD task in BERT paper

In the BERT paper, section 4.2 covers the SQuAD training. From my understanding, there are two extra parameters trained, they are two vectors with the same dimension as the hidden size, so the same ...
1
vote
1answer
65 views

Heavy loss and inaccurate answer in pytorch

As my first AI model I have decided to make an AI model to predict multiplication of two numbers EX - [2,4] = [8]. I wrote the following code, but the loss is very high, around thousands, and it's ...
1
vote
1answer
39 views

Which local minima to choose according to the shape of the error surface?

The following plot shows error function output based on system weights. Two equal local minima are shown in green pointers. Note that the red dots are not related to the question. Considering the ...
1
vote
1answer
49 views

How do I calculate $max_{a′}Q(s′,a′,w−)$ when it is represented as a neural network?

Consider the following loss function $$ L(\mathbf{w}) = [(r + \gamma max_{a'} Q(s', a', \mathbf{w^-})) - Q(s, a, \mathbf{w})]^2 $$ where $Q(s, a, \mathbf{w^-})$ and $Q(s, a, \mathbf{w})$ are ...
1
vote
2answers
245 views

What is the derivative function used in backpropagration?

I'm learning AI, but this confuses me. The derivative function used in backpropagation is the derivative of activation function or the derivative of loss function? These terms are confusing: ...
1
vote
1answer
24 views

Training by one batch of examples, what does it mean

Say I have a batch of examples, each examples represent a state: ...
1
vote
1answer
164 views

Chess policy network

I am interested in making a simple chess engine using neural networks. I already have a fairly good value network but I can't figure out how to train a policy network. I know that Leela chess zero ...
1
vote
0answers
5 views

The best function for lost function, if there are no computationally limations?

I am reading the wiki: https://en.wikipedia.org/wiki/Gradient_boosting There there is written: Unfortunately, choosing the best function $h$ at each step for an arbitrary loss function $L$ is a ...
1
vote
1answer
20 views

Maximize loss on non-target variable

I have a neural network that should be able to classify documents to target label A. The problem is that the network is actually classifying label B, which is an easier task. To make the problem more ...