4e2d8cd89163c0fd4b4e14e4f3d13b58d7e3b29f,examples/nas/naive-tf/train.py,,accuracy,#Any#Any#,56

Before Change


    bs = target.shape[0]
    predicted = tf.cast(tf.argmax(output, 1), target.dtype)
    target = tf.reshape(target, [-1])
    return sum(tf.cast(predicted == target, tf.float32)) / bs


if __name__ == "__main__":
    cifar10 = tf.keras.datasets.cifar10

After Change


def accuracy(truth, logits):
    truth = tf.reshape(truth, -1)
    predicted = tf.cast(tf.math.argmax(logits, axis=1), truth.dtype)
    equal = tf.cast(predicted == truth, tf.int32)
    return tf.math.reduce_sum(equal).numpy() / equal.shape[0]

def accuracy_metrics(truth, logits):
    acc = accuracy(truth, logits)
    return {"accuracy": acc}
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: microsoft/nni
Commit Name: 4e2d8cd89163c0fd4b4e14e4f3d13b58d7e3b29f
Time: 2020-10-18
Author: 40699903+liuzhe-lz@users.noreply.github.com
File Name: examples/nas/naive-tf/train.py
Class Name:
Method Name: accuracy


Project Name: GPflow/GPflow
Commit Name: d57bfbec8e170a6c8517d60b585393b0f3b3c732
Time: 2018-11-05
Author: art.art.v@gmail.com
File Name: gpflow/models/svgp.py
Class Name: SVGP
Method Name: log_likelihood


Project Name: GPflow/GPflow
Commit Name: 6b8a9a5f0e738d98904ff7c46c79a44bfdd56686
Time: 2016-05-31
Author: alexggmatthews@googlemail.com
File Name: GPflow/densities.py
Class Name:
Method Name: multivariate_normal


Project Name: deepmind/sonnet
Commit Name: b4358e3cca1ad1927f4e66f5a0fbc16b13b50686
Time: 2019-06-10
Author: petebu@google.com
File Name: sonnet/src/sgd.py
Class Name: ReferenceSGD
Method Name: apply