# Questions tagged [loss-functions]

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

85 questions
Filter by
Sorted by
Tagged with
53 views

### In which cases is the categorical cross-entropy better than the mean squared error?

In my code, I usually use the mean squared error (MSE), but the TensorFlow tutorials always use the categorical cross-entropy (CCE). Is the CCE loss function better than MSE? Or is it better only in ...
19 views

### What is the difference between batches in deep Q learning and supervised learning?

How is the batch loss calculated in both DQNs and simple classifiers? From what I understood, in a classifier, a common method is that you sample a mini-batch, calculate the loss for every example, ...
31 views

### Why does PyTorch use a different formula for the cross-entropy?

In my understanding, the formula to calculate the cross-entropy is $$H(p,q) = - \sum p_i \log(q_i)$$ But in PyTorch nn.CrossEntropyLoss is calculated using this ...
101 views

### What's the function that SGD takes to calculate the gradient?

I'm struggling to fully understand the stochastic gradient descent algorithm. I know that gradient descent allows you to find the local minimum of a function. What I don't know is what exactly that ...
16 views

### Deduce properties of the loss functions from the training loss curves

I have two convex, smooth loss functions to minimise. During the training (a very simple model) using batch SGD (with tuned optimal learning rate for each loss function), I observe that the (log) loss ...
32 views

### How to understand my CNN's training results?

I created a multi-label classification CNN to classify chest X-ray images into zero or more possible lung diseases. I've been doing some configuration tests on it and analyzing its results and I'm ...
24 views

### Outliers detection problem in neural networks

Assuming we have big m x n input dataset with m x 1 output vector. It's a classification problem with only two possible values: either 1 or 0. Now the problem is that almost all elements of the output ...
6 views

### Should you use the log of the independent variable to train if you're using RMSLE?

So I'm working on an old Kaggle competition which requires you to predict the price of something, and the evaluation metric used is RMSLE. I found a tutorial for that data set, and the person in the ...
15 views

### Using U-NET for image semantic segmentation

If it is not the right place to ask this question, please tell me and I move it to the right place. I'm getting literally crazy trying to understand how U-NET works. Maybe it is very easy but I'm ...
103 views

### How do you interpret this learning curve?

Loss is MSE; orange is validation loss, blue training loss. The task is NN regression (18 inputs, 2 outputs), one layer 300 hidden units. Tuning the lr, mom, l2 regularization parameters this is the ...
41 views

### A generalized quadratic loss and Newton iteration for Support Vector Regression, why doesn't it generalize well?

I'm comparing the results of an Newton optimizer for a modified version of SVM ( a generalized quadratic loss, similar to the one stated in: A generalized quadratic loss for SVM ) with classic SVM^...
21 views

### How would the “best function” been constructed if there are no computationally limitations?

I am reading the Wikipedia article on gradient boosting. There is written: Unfortunately, choosing the best function $h$ at each step for an arbitrary loss function $L$ is a computationally ...
8 views

### Loss function for increasing the quality of the image when labels are not perfectly alligned

I am trying to increse the quality of the images that I gather from the microscope. That is a acoustic microscope and there are lots of technical details but in a nutshell the low quality images and ...
169 views

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

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 ...
38 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-...
31 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 ...
53 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 ...
82 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?
43 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: ...
45 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 ...
21 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 ...
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?
34 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 ...
70 views

### Confused with backprop in pytorch with BCE loss

I've a prediction matrix(P) of dimension 3x3 and one-hot encoded label matrix(L) of dimension 3x3 as shown below. ...
52 views

### TF Keras: How to turn this probability-based classifier into single-output-neuron label-based classifier

Here's a simple image classifier implemented in TensorFlow Keras (right click to open in new tab): https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/quickstart/...
45 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 ...
104 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 ...
41 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 ...
29 views

### How to interpret a large variance of the loss function?

How do I interpret a large variance of a loss function? I am currently training a transformer network (using the software, but not the model from GPT-2) from scratch and my loss function looks like ...
47 views

### Is it possible to use Reward Function of type R(s, a, s') if more than one action is applied?

I am applying a reinforcement learning agent (PPO2, stable baselines implementation) to a custom built environment using OpenAI Gym. One reward function (formualted as loss function, that is, all ...
34 views

### What are the loss functions used in teacher-student learning models?

I am not sure what are the common loss functions people usually use when training a student in a teacher-student learning model. Any insight on this is appreciated.
32 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 ...
62 views

### Are the training loss and validation loss plotted per sample or per batch?

I am using a CNN to train on some data, where training size = 21700 samples, and test size is 653 samples, and say I am using a batch_size of 500 (I am accounting for samples out of batch size as well)...
88 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.
71 views

### LSTM text classifier shows unexpected cyclical pattern in loss

I'm training a text classifier in PyTorch and I'm experiencing an unexplainable cyclical pattern in the loss curve. The loss drops drastically at the beginning of each epoch and then starts rising ...
40 views

### Understanding log probabilities of actions in PPO objective

I'm trying to implement Proximal Policy Optimization algorithm (code here) but am confused about certain concepts:- 1) What is the correct way to implement log probability of a policy (denoted by ...
61 views

### Could the Jensen-Shannon divergence and Kullback-Leibler divergence be used as loss functions of non-generation problems?

If I understand correctly, the KL divergence is a measure of information loss between a ground truth distribution $P$ and a predicted distribution $Q$, and the Jensen-Shannon divergence is the mean of ...
54 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 ...
40 views

### Is it possible with stochastic gradient descent for the error to increase?

As simple as that. Is there any scenario where the error might increase, if only by a tiny amount, when using SGD (no momentum)?
86 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+ ...
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 ...
136 views

### Analysis of Training Loss and Validation Loss Graph

Here I am Showing Two Loss graphs of an Artificial Neural Network. Model 1 Model 2 Blue -training loss Red -val training loss Can you help me to analyse these graphs? I read some articles and ...
14 views

### Limits for a bottleneck

I have some 64x64 pixels frames from a (simulated) video, with a spaceship moving on a fixed background. The spaceship moves in a straight line with constant velocity from left to right (along the x-...
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 ...
24 views

### Why such a big difference in number between training error and validation error?

Question Why such a big difference between my 'Train loss' and 'Validation loss' as shown in the picture below? Is it a signal that my codes are wrong and my trained network is wrong as well? Some ...
63 views

### Unit integral condition on the output layer

I want to train a neural network on some input data from a probability distribution (say a Gaussian). The loss function would normally be $-\sum\log(f(x_i))$, where the sum is over the whole data (or ...
31 views

### Add a layer derivative in the loss function

I am writing a NN in pytorch and I want to add the derivative of the output with respect to one of the inner layers in the loss. Here is a simple example of what I mean: ...
### 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 ...