// Flatten rpn_cls_prob (only anchors, not completely).
rpn_cls_prob = tf.reshape(
rpn_cls_prob, [-1, 2], name="rpn_cls_prob_flatten")
// Now we only have the labels we are going to compare with the
// cls probability. We need to remove the background.
labels = tf.boolean_mask(
rpn_cls_target, labels_not_ignored, name="labels")
cls_prob = tf.boolean_mask(rpn_cls_prob, labels_not_ignored)
// We need to transform `labels` to `cls_prob` shape.
cls_target = tf.one_hot(labels, depth=2)
// TODO: In other implementations they use
// `sparse_softmax_cross_entropy_with_logits` with
// `reduce_mean`. Should we use that?
log_loss = tf.losses.log_loss(cls_target, cls_prob)
// TODO: For logs
cls_loss = tf.identity(log_loss, name="log_loss")
// Finally, we need to calculate the regression loss over `rpn_bbox_target`
// and `rpn_bbox_pred`.
// Since `rpn_bbox_target` is obtained from AnchorTargetLayer then we