74796ff02e9425ca336f595978fe6e7c422c0378,tensorlayer/cost.py,,cross_entropy,#Any#Any#Any#,12

Before Change


    - About cross-entropy: `wiki <https://en.wikipedia.org/wiki/Cross_entropy>`_.\n
    - The code is borrowed from: `here <https://en.wikipedia.org/wiki/Cross_entropy>`_.
    
    with tf.name_scope(name):
        // net_output_tf = output
        // target_tf = target
        // cross_entropy = tf.add(tf.mul(tf.log(net_output_tf, name=None),target_tf),
        //                      tf.mul(tf.log(1 - net_output_tf), (1 - target_tf)))
        // return -1 * tf.reduce_mean(tf.reduce_sum(cross_entropy, 1), name="cross_entropy_mean")
        return tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(output, target))


def binary_cross_entropy(output, target, epsilon=1e-8, name="bce_loss"):
    Computes binary cross entropy given `output`.

    For brevity, let `x = output`, `z = target`.  The binary cross entropy loss is

After Change


        return tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(logits=output, targets=target))
    except: // TF 1.0
        assert name is not None, "Please give a unique name to tl.cost.cross_entropy for TF1.0+"
        return tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(labels=target, logits=output, name=name))

def sigmoid_cross_entropy(output, target, name=None):
    It is a sigmoid cross-entropy operation, see ``tf.nn.sigmoid_cross_entropy_with_logits``.
    
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 3

Instances


Project Name: zsdonghao/text-to-image
Commit Name: 74796ff02e9425ca336f595978fe6e7c422c0378
Time: 2017-04-11
Author: dhsig552@163.com
File Name: tensorlayer/cost.py
Class Name:
Method Name: cross_entropy


Project Name: MorvanZhou/tutorials
Commit Name: 447885e15243dd18d906e2e35ac34ec6dcf9a600
Time: 2016-12-30
Author: morvanzhou@hotmail.com
File Name: Reinforcement_learning_TUT/7_Policy_gradient/RL_brain.py
Class Name: PolicyGradient
Method Name: _build_net


Project Name: tensorlayer/tensorlayer
Commit Name: 0c361196698684acd135c3bae372c92692c1d5e0
Time: 2017-02-14
Author: dhsig552@163.com
File Name: tensorlayer/cost.py
Class Name:
Method Name: cross_entropy


Project Name: tensorflow/cleverhans
Commit Name: 06e9e1f8737c47869ae092c0e769f1e754d4de61
Time: 2018-10-03
Author: windqaq@gmail.com
File Name: cleverhans/picklable_model.py
Class Name: PerImageStandardize
Method Name: fprop