cc8d7ba5562cb2335d975b67e88a81a6bc9b0f46,thinc/loss.py,,categorical_crossentropy,#Any#Any#,8

Before Change


    for i in range(len(labels)):
        target[i, int(labels[i])] = 1.0
        loss += (1.0 - scores[i, int(labels[i])]) ** 2
    return scores - target, loss


@registry.losses("categorical_crossentropy.v0")
def configure_categorical_crossentropy() -> Callable[

After Change




def categorical_crossentropy(scores: Array2d, labels: Array) -> Array2d:
    if labels.ndim != scores.ndim:
        target = to_categorical(labels, n_classes=scores.shape[-1])
    else:
        target = cast(Array2d, labels)
    if scores.shape != target.shape:
        raise ValueError(
            f"Cannot calculate loss: mismatched shapes. {scores.shape} vs {target.shape}"
        )
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: explosion/thinc
Commit Name: cc8d7ba5562cb2335d975b67e88a81a6bc9b0f46
Time: 2020-01-12
Author: honnibal+gh@gmail.com
File Name: thinc/loss.py
Class Name:
Method Name: categorical_crossentropy


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 31a7c3cb9a2f72b7a5c79779f132b2938cb8f3f1
Time: 2019-08-13
Author: beat.buesser@ie.ibm.com
File Name: art/classifiers/xgboost.py
Class Name: XGBoostClassifier
Method Name: predict


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: ebbcfab413f3edfbad00ef84232f6e5e0edfb236
Time: 2019-08-06
Author: beat.buesser@ie.ibm.com
File Name: art/classifiers/scikitklearn.py
Class Name: ScikitlearnClassifier
Method Name: predict