3f9e92e897b00162556361412c68ad1da474f716,tests/classifiersFrameworks/test_pytorch.py,,test_class_gradient,#Any#Any#Any#,178

Before Change



    classifier_logits, _ = get_image_classifier_list(one_classifier=True, from_logits=True)

    expected_gradients_1_all_labels = np.asarray(
        [
            -0.00367321,
            -0.0002892,
            0.00037825,
            -0.00053344,
            0.00192121,
            0.00112047,
            0.0023135,
            0.0,
            0.0,
            -0.00391743,
            -0.0002264,
            0.00238103,
            -0.00073711,
            0.00270405,
            0.00389043,
            0.00440818,
            -0.00412769,
            -0.00441795,
            0.00081916,
            -0.00091284,
            0.00119645,
            -0.00849089,
            0.00547925,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
        ]
    )

    expected_gradients_2_all_labels = np.asarray(
        [
            -1.0557442e-03,
            -1.0079540e-03,
            -7.7426381e-04,
            1.7387437e-03,
            2.1773505e-03,
            5.0880131e-05,
            1.6497375e-03,
            2.6113102e-03,
            6.0904315e-03,
            4.1080985e-04,
            2.5268074e-03,
            -3.6661496e-04,
            -3.0568994e-03,
            -1.1665225e-03,
            3.8904310e-03,
            3.1726388e-04,
            1.3203262e-03,
            -1.1720933e-04,
            -1.4315107e-03,
            -4.7676827e-04,
            9.7251305e-04,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
        ]
    )

    expected_gradients_1_label5 = np.asarray(
        [
            -0.00367321,
            -0.0002892,
            0.00037825,
            -0.00053344,
            0.00192121,
            0.00112047,
            0.0023135,
            0.0,
            0.0,
            -0.00391743,
            -0.0002264,
            0.00238103,
            -0.00073711,
            0.00270405,
            0.00389043,
            0.00440818,
            -0.00412769,
            -0.00441795,
            0.00081916,
            -0.00091284,
            0.00119645,
            -0.00849089,
            0.00547925,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
        ]
    )

    expected_gradients_2_label5 = np.asarray(
        [
            -1.0557442e-03,
            -1.0079540e-03,
            -7.7426381e-04,
            1.7387437e-03,
            2.1773505e-03,
            5.0880131e-05,
            1.6497375e-03,
            2.6113102e-03,
            6.0904315e-03,
            4.1080985e-04,
            2.5268074e-03,
            -3.6661496e-04,
            -3.0568994e-03,
            -1.1665225e-03,
            3.8904310e-03,
            3.1726388e-04,
            1.3203262e-03,
            -1.1720933e-04,
            -1.4315107e-03,
            -4.7676827e-04,
            9.7251305e-04,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
        ]
    )

    expected_gradients_1_label_array = np.asarray(
        [
            -0.00195835,
            -0.00134457,
            -0.00307221,
            -0.00340564,
            0.00175022,
            -0.00239714,
            -0.00122619,
            0.0,
            0.0,
            -0.00520899,
            -0.00046105,
            0.00414874,
            -0.00171095,
            0.00429184,
            0.0075138,
            0.00792443,
            0.0019566,
            0.00035517,
            0.00504575,
            -0.00037397,
            0.00022343,
            -0.00530035,
            0.0020528,
            0.0,
            0.0,
            0.0,
            0.0,
            0.0,
        ]
    )

    expected_gradients_2_label_array = np.asarray(
        [
            5.0867130e-03,
            4.8564533e-03,
            6.1040395e-03,
            8.6531248e-03,
            -6.0958802e-03,
            -1.4114541e-02,
            -7.1085966e-04,
            -5.0330797e-04,
            1.2943064e-02,
            8.2416134e-03,
            -1.9859453e-04,
            -9.8110031e-05,
            -3.8902226e-03,
            -1.2945874e-03,
            7.5138002e-03,
            1.7720887e-03,
            3.1399354e-04,
            2.3657191e-04,
            -3.0891625e-03,
            -1.0211228e-03,
            2.0828887e-03,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
            0.0000000e00,
        ]
    )

    decimal_precision = 4

    expected_values = {
        "expected_gradients_1_all_labels": ExpectedValue(
            expected_gradients_1_all_labels,
            decimal_precision,
        ),
        "expected_gradients_2_all_labels": ExpectedValue(
            expected_gradients_2_all_labels,
            decimal_precision,
        ),
        "expected_gradients_1_label5": ExpectedValue(
            expected_gradients_1_label5,
            decimal_precision,
        ),
        "expected_gradients_2_label5": ExpectedValue(
            expected_gradients_2_label5,
            decimal_precision,
        ),
        "expected_gradients_1_labelArray": ExpectedValue(
            expected_gradients_1_label_array,
            decimal_precision,
        ),
        "expected_gradients_2_labelArray": ExpectedValue(
            expected_gradients_2_label_array,
            decimal_precision,
        ),
    }

    labels = np.random.randint(5, size=x_test_mnist.shape[0])
    backend_test_class_gradient(framework, get_default_mnist_subset, classifier_logits, expected_values, labels)

After Change


    //     ),
    // }

    expected_values = {
        "expected_gradients_1_all_labels": ExpectedValue(
            np.asarray(
                [
                    -0.03347399,
                    -0.03195872,
                    -0.02650188,
                    0.04111874,
                    0.08676253,
                    0.03339913,
                    0.06925241,
                    0.09387045,
                    0.15184258,
                    -0.00684002,
                    0.05070481,
                    0.01409407,
                    -0.03632583,
                    0.00151133,
                    0.05102589,
                    0.00766463,
                    -0.00898967,
                    0.00232938,
                    -0.00617045,
                    -0.00201032,
                    0.00410065,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
        "expected_gradients_2_all_labels": ExpectedValue(
            np.asarray(
                [
                    -0.09723657,
                    -0.00240533,
                    0.02445251,
                    -0.00035474,
                    0.04765627,
                    0.04286841,
                    0.07209076,
                    0.0,
                    0.0,
                    -0.07938144,
                    -0.00142567,
                    0.02882954,
                    -0.00049514,
                    0.04170151,
                    0.05102589,
                    0.09544909,
                    -0.04401167,
                    -0.06158172,
                    0.03359772,
                    -0.00838454,
                    0.01722163,
                    -0.13376027,
                    0.08206709,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
        "expected_gradients_1_label5": ExpectedValue(
            np.asarray(
                [
                    -0.03347399,
                    -0.03195872,
                    -0.02650188,
                    0.04111874,
                    0.08676253,
                    0.03339913,
                    0.06925241,
                    0.09387045,
                    0.15184258,
                    -0.00684002,
                    0.05070481,
                    0.01409407,
                    -0.03632583,
                    0.00151133,
                    0.05102589,
                    0.00766463,
                    -0.00898967,
                    0.00232938,
                    -0.00617045,
                    -0.00201032,
                    0.00410065,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
        "expected_gradients_2_label5": ExpectedValue(
            np.asarray(
                [
                    -0.09723657,
                    -0.00240533,
                    0.02445251,
                    -0.00035474,
                    0.04765627,
                    0.04286841,
                    0.07209076,
                    0.0,
                    0.0,
                    -0.07938144,
                    -0.00142567,
                    0.02882954,
                    -0.00049514,
                    0.04170151,
                    0.05102589,
                    0.09544909,
                    -0.04401167,
                    -0.06158172,
                    0.03359772,
                    -0.00838454,
                    0.01722163,
                    -0.13376027,
                    0.08206709,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
        "expected_gradients_1_labelArray": ExpectedValue(
            np.asarray(
                [
                    0.06860766,
                    0.065502,
                    0.08539103,
                    0.13868105,
                    -0.05520725,
                    -0.18788849,
                    0.02264893,
                    0.02980516,
                    0.2226511,
                    0.11288887,
                    -0.00678776,
                    0.02045561,
                    -0.03120914,
                    0.00642691,
                    0.08449504,
                    0.02848018,
                    -0.03251382,
                    0.00854315,
                    -0.02354656,
                    -0.00767687,
                    0.01565931,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
        "expected_gradients_2_labelArray": ExpectedValue(
            np.asarray(
                [
                    -0.0487146,
                    -0.0171556,
                    -0.03161772,
                    -0.0420007,
                    0.03360246,
                    -0.01864819,
                    0.00315916,
                    0.0,
                    0.0,
                    -0.07631349,
                    -0.00374462,
                    0.04229517,
                    -0.01131879,
                    0.05044588,
                    0.08449504,
                    0.12417868,
                    0.07536847,
                    0.03906382,
                    0.09467953,
                    0.00543209,
                    -0.00504872,
                    -0.03366479,
                    -0.00385999,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                    0.0,
                ]
            ),
            4,
        ),
    }

    labels = np.random.randint(5, size=x_test_mnist.shape[0])
    backend_test_class_gradient(framework, get_default_mnist_subset, classifier_logits, expected_values, labels)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: IBM/adversarial-robustness-toolbox
Commit Name: 3f9e92e897b00162556361412c68ad1da474f716
Time: 2020-07-06
Author: killian.levacher@ibm.com
File Name: tests/classifiersFrameworks/test_pytorch.py
Class Name:
Method Name: test_class_gradient


Project Name: deepmind/dm_control
Commit Name: 904598fd329014cd06e4daa9d6a892d1042f4fca
Time: 2019-02-21
Author: alimuldal@google.com
File Name: dm_control/locomotion/soccer/boxhead.py
Class Name:
Method Name: _asset_png_with_background_rgba_bytes


Project Name: nipy/dipy
Commit Name: 4f3da275037d4fe3108039fdbfc03b2f81fbee8c
Time: 2015-10-15
Author: dimrozakis@gmail.com
File Name: dipy/reconst/dti.py
Class Name:
Method Name: ols_fit_tensor