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
1 answer
What to do next when Deep Learning neural network stop improving in term of validation accuracy?
I was running into this issue where my model converge very fast only after about 20 or 30 epoch
My data set contain 7000 sample and my neural network has 3 hidden layer, each with 18 neurons and batch normalization with drop out 0.2.
My task is a…

Tuong Nguyen Minh
- 155
- 1
- 10
0
votes
1 answer
loss function for YOLO
Can I use this loss function for YOLO
def myLoss(y_actual,y_pred):
a = tf.keras.losses.BinaryCrossentropy()(y_actual[:,:,:,0],y_pred[:,:,:,0])
b = tf.keras.losses.MeanSquaredError()(y_actual[:,:,:,1:],…

hitesh kumar
- 421
- 5
- 8
0
votes
1 answer
Loss function in tf.nn.sampled_softmax_loss
I have a question regarding Tensorflow:
Which loss function is used in tf.nn.sampled_softmax_loss?
I believe it's cross-entropy, but it is not written on the official website. Can anyone confirm my guess?

theabc50111
- 421
- 7
- 16
0
votes
1 answer
How to increase the loss if the predicted value is less than the label but not if it is greater
I use an ai model to make a prediction of a value using mse. Do to noise in the data set, it is impossible for the model to ever give a perfect prediction. What I want to do is if there are two predictions equidistant from a label I want the lower…

Tolure
- 859
- 1
- 14
- 34
0
votes
1 answer
Custom Loss Function in Keras - Iterate through TensorFlow
I am working on creating a custom loss function in Keras.
Here is an example.
import keras.backend as K
def test(y_true, y_pred):
loss = K.square(y_pred - y_true)
loss = K.mean(loss, axis = 1)
return loss
Now in this example, I would…

Toxic Gamer
- 5
- 6
0
votes
0 answers
Dice loss variations (mean, maximal per block)
I use the next simple implementation of dice loss:
def dice_coef(y_true, y_pred):
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f)
return (2. * intersection + 1.) / (K.sum(y_true_f) +…

Green_Wizard
- 795
- 5
- 11
0
votes
2 answers
Why do my val_loss fluctuate and have enormous values while val_categorical_accuracy are more or less constant throughout all epochs?
I adapted the AlexNet architecture, preprocessed the images, augmented the images, used LeakyReLU activation function, utilized dropouts, and had tried adjusting a learning rate. However, these trials aren't improving my model's val_loss and…

Andreas Parasian
- 23
- 1
- 6
0
votes
2 answers
Is the loss function='Multiclass' in catboost same as log loss if I am doing a multiclassification problem?
I am making a multiclass prediction model using catboost, The final solution should have minimum Logloss error but Logloss is not present in catboost, they have something called 'Multiclass' as the loss function. Are they both same? if not then how…

swapnil agashe
- 69
- 1
- 12
0
votes
1 answer
Truly understanding Cross-Entropy-Loss
I have a machine learning course, where I have to implement the forward and backward method of the CELoss:
class CELoss(object):
@staticmethod
def forward(x, y):
assert len(x.shape) == 2 # x is batch of predictions (batch_size,…

spadel
- 998
- 2
- 16
- 40
0
votes
0 answers
How to define custom loss function in keras for Autoencoder using VGG as encoder, with bounding boxes as input along the input image?
issue 1: How to take arbitrary number of bounding box for image ? is it recommended to take 1 bounding boxes for image and do same for all bounding box ?
issue 2: I am struggling the custom loss function, so far I have come is this
def…

rakeshKM
- 53
- 6
0
votes
1 answer
Loss function and Last layer for numeric output
I'm trying to train a convolutional neural network to read the consumption index from a valid picture of a meter. The consumption is an integer that can vary from 0 to 99999.
What loss function should I use, what is the appropriate shape for the…

W.314
- 156
- 8
0
votes
0 answers
InvalidArgumentError: Expected size[0] in [0, 0], but got 1
I'm trying to train a nueral net using categorical crossentropy loss but am getting
InvalidArgumentError: Expected size[0] in [0, 0], but got 1
[[node loss_4/dense_18_loss/categorical_crossentropy/softmax_cross_entropy_with_logits/Slice_1…

Daniel
- 2,435
- 5
- 26
- 40
0
votes
1 answer
tf.keras mean_squared_error strange return when data length > batch size
MSE as a loss function in a sequential model, does not work properly when data length > batch size.
Let's start with data length < 32.
In this case it works fine, next we'll do the same with 3 more values in data.
Firstly we get our data, then we…

Jackie Boscher
- 1
- 1
0
votes
1 answer
how to count how many times appear a value on a 2D Tensor: UniqueWithCounts only supports 1D Tensor
I'm learning Tensorflow 2.10, with Python 3.7.7.
I'm trying to use the tutorial "Tensorflow - Custom training: walkthrough" to use my own loss function.
This is my first version of loss function, and it works:
def loss(model, x, y):
output =…

VansFannel
- 45,055
- 107
- 359
- 626
0
votes
1 answer
Calculating negative ELBO
I am going through the tutorial of deep Markov models where they are trying to learn the polyphonic dataset. The Link to tutorial is:
https://pyro.ai/examples/dmm.html
This model parameterises transitions and emissions with using a neural network…

John
- 815
- 11
- 31