Questions tagged [loss]
599 questions
5
votes
1 answer
How to use weighted categorical crossentropy on FCN (U-Net) in Keras?
I have built a Keras model for image segmentation (U-Net). However in my samples some misclassifications (areas) are not that important, while other are crucial, so I want to assign higher weight in loss function to them. To complicate things…

johndodo
- 17,247
- 15
- 96
- 113
5
votes
2 answers
Android: 3G to WIFI switch while in the middle on the app = loss of network connectivity
I am running into a annoying problem with HTC Legend (Android 2.2). Not seeing this issue on Xperia, Galaxy, Nexus, etc.
When I launch my app on a 3G connection, fetch some data, then go into phone Settings and enable WIFI, the phone automatically…

Saideira
- 2,374
- 6
- 38
- 49
5
votes
1 answer
Java reflection loss of annotation information
I'm having an issue with reflection. I decided I wanted to create a SQL Query Generator using reflection. I created my own annotations to determine what classes can be used, what attributes can be stored ect.
The code works as I want it to, however…

billy.mccarthy
- 122
- 1
- 11
4
votes
1 answer
Is it a good idea to Multiply loss().item by batch_size to get the loss of a batch when batch size is not a factor of train_size?
Suppose we have problem where we have 100 images and a batch size of 15. We have 15 images in all of out batches except our last batch which contains 10 images.
Suppose we have network training as:
network = Network()
optimizer =…

Deshwal
- 3,436
- 4
- 35
- 94
4
votes
2 answers
AttributeError: 'Tensor' object has no attribute 'numpy' in custom loss function (Tensorflow 2.1.0)
I want to train a model with a custom loss function, in order to do that, I need to convert the tensor to numpy array inside the method below:
def median_loss_estimation(y_true, y_predicted):
a = y_predicted.numpy()
but I have this…

Francesco Scala
- 201
- 3
- 15
4
votes
1 answer
Single Loss for Multiple Outputs
I would like to create a neural network in Keras/Tensorflow which has multiple outputs. I would like to create a SINGLE loss function which takes all outputs into account and computes the loss accordingly. I need to do this because the outputs are…

lenngro
- 110
- 10
4
votes
0 answers
Is there a way to make keras ignore a label when computing binary_crossentropy loss?
I'm writing a custom loss function for a (sort of) semantic segmentation task where I compute binary crossentropy (using keras backend) for the target (2-d array) and predictions. The overall loss is a sum of 4 different loss functions.
In two of…

Gautham Venkataraman
- 81
- 4
4
votes
1 answer
How should I interpret the output of the sparse_categorical_crossentropy function?
As an input a have a float 1.0 or 0.0. When I try to predict with my model and the sparse_categorical_crossentropy loss I get something like:
[[0.4846592 0.5153408]].
How do I know what category it predicts?

user9468014
- 479
- 2
- 6
- 20
4
votes
1 answer
Why isn't my XOR tensorflow network learning?
I can't figure out what I'm doing wrong with this XOR neural network. Maybe I'm not computing the loss correctly? The loss improves slightly at the beginning, and then the accuracy converges to 50% very quickly. Could someone please point out what…

Austin
- 6,921
- 12
- 73
- 138
4
votes
4 answers
Comparing MSE loss and cross-entropy loss in terms of convergence
For a very simple classification problem where I have a target vector [0,0,0,....0] and a prediction vector [0,0.1,0.2,....1] would cross-entropy loss converge better/faster or would MSE loss?
When I plot them it seems to me that MSE loss has a…

aa1
- 783
- 1
- 15
- 31
4
votes
1 answer
Which one is more efficient: tf.where or element-wise multiplication?
I'm implementing a loss function that will use a mask tensor(M) consisting of 0s and 1s to eliminate some loss values given predictions(P) and ground-truth(G) tensors.
So, I have 2 possible ways:
Element-wise multiplication:
loss = K.sum(M *…

mkocabas
- 703
- 6
- 19
4
votes
2 answers
TensorFlow loss function zeroes out after first epoch
I am trying to implement a discriminative loss function for instance segmentation of images based on this paper: https://arxiv.org/pdf/1708.02551.pdf (This link is just for the readers' reference; I don't expect anyone to read it to help me out!)
My…

Shruthi Kubatur
- 43
- 1
- 5
4
votes
1 answer
Loss in Tensorflow suddenly turn into nan
When I using tensorflow, the loss suddenly turn into nan, just like:
Epoch: 00001 || cost= 0.675003929
Epoch: 00002 || cost= 0.237375346
Epoch: 00003 || cost= 0.204962473
Epoch: 00004 || cost= 0.191322120
Epoch: 00005 || cost=…

Qiang Zhang
- 820
- 8
- 32
4
votes
1 answer
java - android UDP unreliability
I am having extreme UDP packet losses with Android and it does not make sense. The situation is as follows:
PC running java client connected to home network
Phone running java server (android) connected to home network
Home router is a brand new…

Enk73a
- 49
- 2
4
votes
2 answers
PySerial loses data
My problem is, that PySerial seems to lose some data packages and I don't know why.
I have two python scripts, the first one reads data from a text file and writes it to a microcontroller, where the data is manipulated. Then, the microcontroller…

user2494129
- 717
- 2
- 13
- 24