Questions tagged [loss-function]

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.

1727 questions
0
votes
1 answer

Keras loss function value doesn't decrease

I'm implementing an MLP with Keras, I notice that the loss function doesn't change during epochs. I tried to varying learning rate and the weights initialization, but nothing changed. Here's the code: mlp = keras.models.Sequential() # add input…
pairon
  • 427
  • 1
  • 7
  • 18
0
votes
2 answers

Indexing a tf variable in loss function

I define a custom loss function in Tensorflow 1.9.0 (can't upgrade due to project restrictions). I have the following variables, obtained after an eigenvalue decomposition: # eigw.shape = (?, x) # eigv.shape = (?, x, y) Now, I want to calculate the…
Nico
  • 13
  • 4
0
votes
0 answers

Custom loss function getting constant loss

I am trying to compute loss based on the output of intermediate layers of 2 models, after which I applied an Average layer to get the output. I am not very sure on how to do it. The loss function is defined in this paper, and I have implemented…
naomity
  • 83
  • 1
  • 5
0
votes
0 answers

tf.boolean_mask in loss function: No gradients provided for any variable

I am trying to use tf.boolean_mask to get a masked mean difference for image segmentation: def custom_loss(image): def loss(predicted_y, target_y): pred_mask = tf.math.greater(predicted_y,0.5) target_mask =…
0
votes
0 answers

Keras compile() function takes very much time with custom loss function

I'm implementing an MLP with Keras and a custom loss function. I notice model.compile() takes very much time: it seems doesn't end. The loss that I passed to the compile() function is custom. I'm also using another function that is used in the loss…
pairon
  • 427
  • 1
  • 7
  • 18
0
votes
1 answer

What's the cleanest and most efficient way to pass two stereo images to a loss function in Keras?

First off, why am I using Keras? I'm trying to stay as high level as possible, which doesn't mean I'm scared of low-level Tensorflow; I just want to see how far I can go while keeping my code as simple and readable as possible. I need my Keras model…
kmf
  • 49
  • 1
  • 17
0
votes
1 answer

I got a NaN in loss function of Keras from the first epoch

I got a NaN loss from the first epoch. The shape of train_data is (891,13). The shape of train_labels is (891,2). I create this model for titanic competition in Kaggle. from keras import models from keras import layers import tensorflow as tf def…
0
votes
1 answer

Expected to see 3 array(s), but instead got the following list of 1 arrays:

I am trying to train a triple loss model using a fit_generator. it requires three input and no output. so i have a function that generates hard triplets. the output from the triplets generator has a shape of (3,5,279) which is 3…
0
votes
1 answer

Customized keras loss function using min_g(g, g*)

I am dealing with a regression problem where given an image, I want to predict the value of 3 parameters (cartesian coordinates) . For the same image I can have several acceptable coordinates. To do this, I use a neural network using keras. To train…
0
votes
1 answer

My model doesn't seem to work, as accuracy and loss are 0

I tried to design an LSTM network using keras but the accuracy is 0.00 while the loss value is 0.05 the code which I wrote is below. model = tf.keras.models.Sequential() model.add(tf.keras.layers.Flatten()) model.add(tf.keras.layers.Dense(128,…
0
votes
1 answer

How to produce a variable size distance matrix in keras?

What I am trying to achieve now is to create a custom loss function in Keras that takes in two tensors (y_true, y_pred) with shapes (None, None, None) and (None, None, 3), respectively. However, the None's are so, that the two shapes are always…
0
votes
0 answers

loss not chnging after 300 iteration

my loss start high 0.65 then reduce until reach 0.01 and stop changing, when I check result still not good , should I wait , or what I have to do ? my activation function is lrelu last layer sigmoid my loss function binary cross entropy all layers…
user3029270
  • 59
  • 2
  • 10
0
votes
1 answer

categorical_crossentropy expects targets to be binary matrices

First of all I am not a programmer, but I am self-teaching me Deep Learning to undertake a real project with my own dataset. My situation can be broken down as follows: I am trying to undertake a multiclass text classification project. I have a…
0
votes
1 answer

Losses keep increasing within iteration

I am just a little confused on the following: I am training a neural network and have it print out the losses. I am training it over 4 iterations just to try it out, and use batches. I normally see loss functions as parabolas, where the losses would…
formicaman
  • 1,317
  • 3
  • 16
  • 32
0
votes
0 answers

Can you provide loss_weights when using add_loss?

In tensorflow 2, when using multiple losses added with model.add_loss, when doing model.compile, can you pass loss_weights argument to make the model loss a weighted sum of the losses added? Something like…