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
1
vote
0answers
24 views

When and How to use a mix of Loss Functions for back propagation?

Trying to understand the best loss function to be used with CNN, I came to know that we can mix two loss functions. Can any body share in what case was it done and how?
1
vote
1answer
27 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 ...
0
votes
1answer
42 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. ...
0
votes
1answer
43 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/...
1
vote
0answers
45 views

Why the loss keep increasing during training?

I'm trying to use TensorFlow and this how I compute the loss ...
2
votes
0answers
37 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 ...
3
votes
1answer
51 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 ...
2
votes
0answers
37 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 ...
1
vote
0answers
23 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 ...
1
vote
0answers
45 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 ...
0
votes
0answers
27 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.
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
44 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)...
2
votes
2answers
58 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.
1
vote
1answer
61 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 ...
0
votes
0answers
24 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 ...
1
vote
0answers
36 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 ...
1
vote
1answer
44 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 ...
0
votes
1answer
38 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)?
2
votes
1answer
53 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
0answers
29 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 ...
0
votes
1answer
36 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 ...
0
votes
0answers
12 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-...
2
votes
1answer
39 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 ...
0
votes
0answers
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 ...
1
vote
0answers
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 ...
1
vote
0answers
30 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: ...
4
votes
3answers
192 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 ...
2
votes
2answers
62 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_{...
0
votes
0answers
50 views

A2C Critic Loss Interpretation

I'm working on an Advantage A2C implementation, and I just finished creating the value network $\hat{V_{\phi}}$. I train this network with the standard MSE loss of discounted rewards-to-go:$$\|\hat{V_{...
1
vote
1answer
30 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 ...
0
votes
1answer
74 views

Artifacts After pruning Unet CNN

Im trying to make a dark image brighter using CNN-UNet arcitecture. When I train the network I get the following results: When I cut the features in half for pruning, and do full train again, I get ...
2
votes
0answers
31 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|...
4
votes
1answer
129 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 ...
1
vote
3answers
52 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 ...
2
votes
1answer
100 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 ...
1
vote
1answer
25 views

Having trouble figuring out how loss was calculated for SQuAD task in BERT paper

The BERT Paper https://arxiv.org/pdf/1810.04805.pdf Section 4.2 covers the SQuAD training. So from my understanding, there are two extra parameters trained, they are two vectors with the same ...
5
votes
1answer
267 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, \...
0
votes
1answer
240 views

Why isn't the reverse KL divergence commonly used in supervised learning?

Forward KL Divergence (also known as cross entropy loss) is a standard loss function in supervised learning problems. I understand why it is so: matching a known a trained distribution to a known ...
0
votes
0answers
11 views

How is the length of an input sequence related to the structure of an RNN?

My question is only with regards to the feedforward part of an RNN. I am following these steps. I am working on prediction of a time series. The time series is a toy model generated by me. It is ...
1
vote
1answer
55 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 ...
2
votes
2answers
79 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
1answer
38 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 ...
3
votes
2answers
58 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 ...
1
vote
1answer
68 views

How do I get multiple loss per sample in keras evaluate?

Usually, when I evaluate() a model, I would get a single loss that is already averaged over all samples. How do I get the loss per each sample and return all of them? E.g. if my dataset has 100 ...
3
votes
1answer
75 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 ...
0
votes
2answers
95 views

Loss function spikes

For the UNSW-NB15 dataset i receive spikes in the loss function during training. The algorithms see part of this UNSW dataset a single time. Loss function is plotted after every batch. For other ...
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 ...
0
votes
1answer
65 views

inconsistent formulas for loss calculation in OpenAI's Actor Critic?

Open Ai's (working) actor critic code calculates the losses like so: ...
2
votes
1answer
57 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. ...