Questions tagged [loss]

599 questions
9
votes
3 answers

How is PyTorch's Class BCEWithLogitsLoss exactly implemented?

According to the PyTorch documentation, the advantage of the class BCEWithLogitsLoss() is that one can use the log-sum-exp trick for numerical stability. If we use the class BCEWithLogitsLoss() with the parameter reduction set to None, they have a…
Hermi
  • 350
  • 2
  • 5
  • 16
9
votes
2 answers

Keras - Loss and Metric calculated differently?

I have a model in Keras which I'm optimizing the mean squared error. However, if I use the same code as in losses.py from Keras in the metric, I get a different result. Why is this? As a metric: def MSE_metric(y_true, y_pred): return…
user3126802
  • 419
  • 8
  • 19
9
votes
3 answers

Keras Implementation of Customized Loss Function that need internal layer output as label

in keras, I want to customize my loss function which not only takes (y_true, y_pred) as input but also need to use the output from the internal layer of the network as the label for an output layer.This picture shows the Network Layout Here, the…
ljklonepiece
  • 211
  • 2
  • 8
9
votes
1 answer

Tensorflow: loss resets after successfully restored checkpoint

There are no errors when saving or restoring. The weights appear to have restored correctly. I am trying to build my own minimal character level RNN by following karpathy/min-char-rnn.py, sherjilozair/char-rnn-tensorflow, and the Tensorflow RNN…
King Long Tse
  • 295
  • 1
  • 2
  • 10
8
votes
3 answers

YOLOv8 dfl_loss metric

I was wondering how to interpret different losses in the YOLOv8 model. I've easily found explanations about the box_loss and the cls_loss. About the dfl_loss I don't find any information on the Internet. I've also checked the YOLOv8 Docs. I've found…
caro.mss
  • 81
  • 1
  • 3
8
votes
1 answer

Train multi-output regression model in pytorch

I'd like to have a model with 3 regression outputs, such as the dummy example below: import torch class MultiOutputRegression(torch.nn.Module): def __init__(self): super(MultiOutputRegression, self).__init__() self.linear1 =…
user1315621
  • 3,044
  • 9
  • 42
  • 86
8
votes
2 answers

Loss does not decrease during training (Word2Vec, Gensim)

What can cause loss from model.get_latest_training_loss() increase on each epoch? Code, used for training: class EpochSaver(CallbackAny2Vec): '''Callback to save model after each epoch and show training parameters ''' def __init__(self,…
Dasha
  • 327
  • 2
  • 10
8
votes
1 answer

Cross entropy loss in pytorch nn.CrossEntropyLoss()

maybe someone is able to help me here. I am trying to compute the cross entropy loss of a given output of my network print output Variable containing: 1.00000e-02 * -2.2739 2.9964 -7.8353 7.4667 4.6921 0.1391 0.6118 5.2227 6.2540 …
Elias E.
  • 101
  • 1
  • 1
  • 8
8
votes
2 answers

Keras Extremely High Loss

I'm trying to predict price by characteristics. I chose a pretty simple model, but it works very strange. Loss function is extremely high and I can't see where the problem is. Here is my model: # define base model def baseline_model(): # create…
8
votes
1 answer

The loss function decreases, but accuracy on train set does not change in tensorflow

I am trying to implement a simple gender classifier using deep convolutional neural networks using tensorflow. I have found this model and implemented it. def create_model_v2(data): cl1_desc = {'weights':weight_variable([7,7,3,96]),…
7
votes
1 answer

Higher loss penalty for true non-zero predictions

I am building a deep regression network (CNN) to predict a (1000,1) target vector from images (7,11). The target usually consists of about 90 % zeros and only 10 % non-zero values. The distribution of (non-) zero values in the targets vary from…
Lukas Hecker
  • 73
  • 1
  • 4
7
votes
2 answers

loss calculation over different batch sizes in keras

I know that in theory, the loss of a network over a batch is just the sum of all the individual losses. This is reflected in the Keras code for calculating total loss. Relevantly: for i in range(len(self.outputs)): if i in…
Jonathan
  • 1,876
  • 2
  • 20
  • 56
7
votes
2 answers

Different loss function for validation set in Keras

I have unbalanced training dataset, thats why I built custom weighted categorical cross entropy loss function. But the problem is my validation set is balanced one and I want to use the regular categorical cross entropy loss. So can I pass…
W. Sam
  • 818
  • 1
  • 7
  • 21
7
votes
3 answers

How to get results from custom loss function in Keras?

I want to implement a custom loss function in Python and It should work like this pseudocode: aux = | Real - Prediction | / Prediction errors = [] if aux <= 0.1: errors.append(0) elif aux > 0.1 & <= 0.15: errors.append(5/3) elif aux > 0.15 & <=…
Aceconhielo
  • 3,316
  • 4
  • 19
  • 26
7
votes
1 answer

What is the ideal value of loss function for a GAN

GAN originally proposed by IJ Goodfellow uses following loss function, D_loss = - log[D(X)] - log[1 - D(G(Z))] G_loss = - log[D(G(Z))] So, discriminator tries to minimize D_loss and generator tries to minimize G_loss, where X and Z are training…
1
2
3
39 40