I am doing a semantic segmentation task using tensorflow. I have 5 classes, I calculate the loss like this:
loss = tf.reduce_mean((tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=tf.squeeze(annotation, squeeze_dims=[3]), name="entropy")))
logits
has shape (batch_size, picture_height, picuture_width, 5)
annotation
has shape (batch_size, picture_height, picuture_width, 1)
Now I only want to calculate the loss of the first 4 classes, ignore the 5th class. How can I achieve this?
For example, if I only want to calulate the Cohen's kappa of the first 4 classes, I can set the labels
parameter in sklearn.metrics.cohen_kappa_score:
kappa = cohen_kappa_score(y_true, y_pred, labels=[0,1,2,3])