If Y_pred
is very far off from Y
, the Loss value will be very high. However, if both values are almost similar, the Loss value will be very low. Hence we need to keep a loss function which can penalize a model effectively while it is training on a dataset.
When a neural network is trying to predict a discrete value, we can consider it to be a classification model. This could be a network trying to predict what kind of animal is present in an image, or whether an email is a spam or not.
Questions tagged [loss-function]
1727 questions
0
votes
0 answers
The size of tensor a (10) must match the size of tensor b (9) at non-singleton
i am using this code earlier in Jupiter notebook it was not showing error but accuracy was veryless then i have tried the same code in google colab there it is showing error, please suggest some way to increase accuracy . i am trying to perform…

prashant
- 11
- 1
- 4
0
votes
0 answers
Getting Nan for custom loss function in Keras for time series regression encoder-decoder model
I have read some of the other topics that are about this issue, but I don't understand how to solve it in my case as the loss functions they use are usually a lot more complex than mine. I believe the answer is about adding a small value like 1e-10…

Kevin
- 35
- 1
- 4
0
votes
3 answers
Keras custom loss function using other arguments than y_pred and y_true
I was thinking the idea of using a perceptron-like neural network to solve my problem. I have a dataset that, for the sake of simplicity, looks like this:
id entryWoodLength entryWoodThickness cuttingToolPos1 cuttingToolPos2 exitWoodLength…

Guillaume Giroux
- 21
- 4
0
votes
1 answer
Loss function and data format for training a ''categorical input' to 'categorical output' model?
I am trying to train a model for autonomous driving that converts input from the front camera, to a bird's eye view image.
The input and output, both are segmentation masks with shape (96, 144) where each pixel has a range from 0 to 12 (each number…

user52610
- 11
- 1
- 4
0
votes
1 answer
interpreting strange output from keras.predict
im using keras for a multiclass clasffication of text-comments problem, this one, to be precise:
https://www.kaggle.com/c/jigsaw-toxic-comment-classification-challenge
There is six classes, and the observations could fall in all of them. I have…

s3j80
- 143
- 1
- 1
- 9
0
votes
0 answers
how to call a pre-trained decoder model in custom loss function in keras?
I trained a auto-encoder model before and saved decoder model. Next, I train a new model that labeled as 'netA', I want to use decoder model in custom loss function. and tried, but I got error, there was my code and error information:
def…

haidan li
- 49
- 6
0
votes
1 answer
Error with custom loss function in CVAE model using Keras
Im trying to build a Convolutional Variational Auto Encoder(CVAE) and therefore I have to build the vae_loss() function, which is a combination of a MSE and a KL Divergence loss function. It looks like follows:
def vae_loss(y_true, y_pred):
#…

Desperate Morty
- 66
- 2
- 11
0
votes
0 answers
Triplet-Loss using pre-trained network
I am trying to use the Triple-Loss technique to fine-tune an EfficientNet network for human Re-ID using Keras. Here is the code I am using:
This is the generator:
class SampleGen(object):
def __init__(self, file_class_mapping):
…
0
votes
1 answer
Tensorflow & Keras: Different output shape depends on training or inferring
I am sub-classing tensorflow.keras.Model to implement a certain model. Expected behavior:
Training (fitting) time: returns a list of tensors including the final output and auxiliary output;
Inferring (predicting) time: returns a single output…

Meow Cat 2012
- 928
- 1
- 9
- 21
0
votes
1 answer
How should i define loss and performance metric for this CNN?
I have implemented a CNN with two output layers for GTSRB Dataset problem. One output layer classifies images into their respective classes and second layer predicts bounding box coordinates. In dataset, the upper left and lower right coordinate is…

Hardik Vagadia
- 355
- 2
- 10
0
votes
0 answers
PyTorch Two Losses of Two Variables
This is a question about PyTorch autograd.grad and the backward function specifically.
I have two tensors a, b which are optimized over (i.e. require gradients).
I define loss1, loss2 = f(a,b), g(a,b). Although these are two separate functions f and…

akarshkumar0101
- 367
- 2
- 10
0
votes
0 answers
Neural Network Loss Function and how to add a Constant Value to it
I have a neural network model with only convolutional layers and need some help with the loss function.
I am reading a paper which suggests to add a constant which is proportional to something called an 'energy' which can be calculated from the…

hegal
- 81
- 7
0
votes
1 answer
Y_True in Loss Function not Correct
I am building my loss function. However, when printing the value of the y_true tensor it is printing values with decimal points (i.e 0.25,0.569,0.958). This should not be true as the y_true should only have two classes 0 or 1. Here is my…

devdeep
- 1
- 1
0
votes
1 answer
Loss function provide NAN gradient
I used histogram loss as a loss function for my model but it provide NAN gradient.
Code snippet (loss function):
def histogram_loss(y_true, y_pred):
h_true = tf.histogram_fixed_width( y_true, value_range=(-1., 1.), nbins=20)
h_pred =…

reshadshuvo123
- 189
- 2
- 12
0
votes
0 answers
How to find loss function values in unsupervised learning with Autoencoder?
To simplify my story: I was trying to test dimensionality reduction on my UNLABELED data with the encoder method using keras/tensorflow.
So I looked at the internet and found a nice code that might be useful for me. Here's the link:…

user026
- 638
- 4
- 14