All Questions
Tagged with keras loss-function
116
questions
0
votes
0
answers
14
views
Why does the TensorFlow docs use a different GAN generator loss?
As per the original paper that introduced GANs, the generator loss is given as:
$$
L_{G} = L _{BCE}(\mathbf{\vec 0}, \mathbf{D}(\mathbf{G}(\mathbf{\vec z}))) = \log(1 - \mathbf{D}(\mathbf{G}(\mathbf{\...
2
votes
1
answer
51
views
Custom loss function in python
I am trying to implement a custom loss function inspired by https://arxiv.org/pdf/2305.10464.pdf. That is:
$ L(\mathbf{x}) = (1-y) \left\lVert \mathbf{x_{true} - \mathbf{x_{pred}}} \right\rVert^2 + y \...
1
vote
1
answer
50
views
Does using different optimizer change the loss landscape
I plot the landscape using this code, and I notice the landscape shape has changed a lot. My understanding is that the optimizer does not change the loss landscape. But now I'm confused if its just ...
0
votes
1
answer
37
views
My custom neural network is converging but keras model not
in most cases it is probably the other way round but...
I have implemented a basic MLP neural network structure with backpropagation. My data is just a shifted quadratic function with 100 samples. I ...
0
votes
0
answers
15
views
Meaning of mean squared error in multistep prediction
In multistep prediction with LSTM(keras), say we had this kind of result:
target = [[1,2,3] ,[4,5,6] ]
predictions = [[1.1,2.2,3.3] , [4.4,5.5,6.6]]
When we choose mean_squared_error as the loss ...
0
votes
0
answers
137
views
Custom Loss Function Returns Graph Execution Error: Can not squeeze dim[0], expected a dimension of 1, got 32
I have built a loss function which adds time and frequency weighted averages and variances to the MSE:
...
0
votes
0
answers
110
views
Custom loss and metric functions including additional parameter in Keras
The following example is based on this approach.
Similar to that approach, I am wanting to pass an additional parameter with y_true for my custom metric, as both will be used in the computation of ...
0
votes
1
answer
83
views
Transpose of a 3D tensor
I need to transpose a 3-dimensional tensor of the shape (batch_size, N, M) to (batch_size, M, N) in a custom loss function in Keras with tensorflow as the backend. I tried using the following function
...
0
votes
0
answers
30
views
How to implement a custom loss function acting differently on multiple instances with keras?
I want to reproduce the results in "Online Neural Networks for Change-Point Detection" Hushchyn et al., but I'm having trouble implementing their loss function with Keras. The algorithm ...
2
votes
0
answers
734
views
The val_loss is nan, but loss is printing. Both train and validation losses are nan in model.evaluate(), and the acc improves during training
There is a 2-class classification problem, and my loss function is custom. The labels are categorical, and the final activation function is Softmax. During the training, the loss is printed, but the ...
1
vote
0
answers
94
views
problem on designing a custom_loss function
I am using CNN to solve a regression problem in a supervised manner. i have input data(X_train) and the target data(y_train). I allow the network to train and during training process in each batch of ...
0
votes
1
answer
381
views
Can I have 0 loss in the validation set and still have bad accuracy?
I am starting in the world of deep neural networks and doing a series of tests with a convolutional model, I have found the following case:
The accuracy in the training set is much better (around 0.85)...
0
votes
1
answer
131
views
Define a custom distance between classes in Keras
How is it possible to make a classification with custom distance between classes in Keras?
For example, let's say I need to classify betweenA1,...
0
votes
0
answers
313
views
Custom loss function for binary classificatio in Keras gets error: No gradients provided for any variable
I have a binary classification problem. However, I don't really care about fp and fn values. What I want to achieve is that the <...
1
vote
0
answers
227
views
Adding a group specific penalty to binary cross-entropy
I want to implement a custom Keras loss function that consists of plain binary cross-entropy plus a penalty that increases the loss for false negatives from one class (each observation can belong to ...