def kld_loss(teacher_logits, student_logits, labels, distill_temperature, task_balance):
    student_task_xent = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.squeeze(labels), logits=student_logits)
    student_distill = tf.reduce_sum((tf.nn.softmax((student_logits / distill_temperature)) * tf.log((tf.nn.softmax(((student_logits / distill_temperature) + 1e-05)) - tf.log(tf.nn.softmax(((teacher_logits / distill_temperature) + 1e-05)))))))
    losses = (task_balance * tf.reduce_mean(student_task_xent))
    losses += ((1 - task_balance) * tf.reduce_mean(student_distill))
    return losses
def kld_loss(teacher_logits, student_logits, labels, distill_temperature, task_balance):
    student_task_xent = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=tf.squeeze(labels), logits=student_logits)
    student_distill = tf.reduce_sum((tf.nn.softmax((student_logits / distill_temperature)) * tf.log((tf.nn.softmax(((student_logits / distill_temperature) + 1e-05)) - tf.log(tf.nn.softmax(((teacher_logits / distill_temperature) + 1e-05)))))))
    losses = (task_balance * tf.reduce_mean(student_task_xent))
    losses += ((1 - task_balance) * tf.reduce_mean(student_distill))
    return losses