import tensorflow as tf

    cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
        logits=logits, labels=labels, name='xentropy')
    weight = tf.convert_to_tensor(weight, dtype=logits.dtype.base_dtype, name='loss_weight')
    loss = tf.multiply(weight, tf.reduce_mean(cross_entropy), name='value')
