e5b0e4f15d23be74d3bd34beb8e4a4b17634575b,tests/attacks/evasion/test_frame_saliency.py,,test_iterative_saliency_refresh,#Any#Any#,89
Before Change
@pytest.mark.skipMlFramework("pytorch")
def test_iterative_saliency_refresh(fix_get_mnist_subset, image_dl_estimator_for_attack):
classifier_list = image_dl_estimator_for_attack(FastGradientMethod)
// TODO this if statement must be removed once we have a classifier for both image and tabular data
if classifier_list is None:
logging.warning("Couldn"t perform this test because no classifier is defined")
return
expected_values_axis_1 = {"nb_perturbed_frames": ExpectedValue(np.asarray([5, 1, 3, 10, 8, 1, 3, 8, 4, 7, 7]), 2)}
expected_values_axis_2 = {"nb_perturbed_frames": ExpectedValue(np.asarray([11, 1, 2, 6, 14, 2, 2, 13, 4, 8, 4]), 2)}
for classifier in classifier_list:
attacker = FastGradientMethod(classifier, eps=0.3, batch_size=128)
attack = FrameSaliencyAttack(classifier, attacker, "iterative_saliency_refresh")
backend_check_adverse_frames(attack, fix_get_mnist_subset, expected_values_axis_1)
// test with non-default frame index:
attack = FrameSaliencyAttack(classifier, attacker, "iterative_saliency", frame_index=2)
backend_check_adverse_frames(attack, fix_get_mnist_subset, expected_values_axis_2)
def test_classifier_type_check_fail():
backend_test_classifier_type_check_fail(FastGradientMethod, [LossGradientsMixin, BaseEstimator])
After Change
@pytest.mark.skipMlFramework("pytorch")
@pytest.mark.framework_agnostic
def test_iterative_saliency_refresh(fix_get_mnist_subset, image_dl_estimator_for_attack):
try:
classifier = image_dl_estimator_for_attack(FastGradientMethod)
expected_values_axis_1 = {"nb_perturbed_frames": ExpectedValue(np.asarray([5, 1, 3, 10, 8, 1, 3, 8, 4, 7, 7]), 2)}
expected_values_axis_2 = {"nb_perturbed_frames": ExpectedValue(np.asarray([11, 1, 2, 6, 14, 2, 2, 13, 4, 8, 4]), 2)}
attacker = FastGradientMethod(classifier, eps=0.3, batch_size=128)
attack = FrameSaliencyAttack(classifier, attacker, "iterative_saliency_refresh")
backend_check_adverse_frames(attack, fix_get_mnist_subset, expected_values_axis_1)
// test with non-default frame index:
attack = FrameSaliencyAttack(classifier, attacker, "iterative_saliency", frame_index=2)
backend_check_adverse_frames(attack, fix_get_mnist_subset, expected_values_axis_2)
except ARTTestException as e:
add_warning(e)
@pytest.mark.framework_agnostic
def test_classifier_type_check_fail():
try:
backend_test_classifier_type_check_fail(FastGradientMethod, [LossGradientsMixin, BaseEstimator])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 14
Instances
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: e5b0e4f15d23be74d3bd34beb8e4a4b17634575b
Time: 2020-09-23
Author: killian.levacher@ibm.com
File Name: tests/attacks/evasion/test_frame_saliency.py
Class Name:
Method Name: test_iterative_saliency_refresh
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: e5b0e4f15d23be74d3bd34beb8e4a4b17634575b
Time: 2020-09-23
Author: killian.levacher@ibm.com
File Name: tests/attacks/evasion/test_frame_saliency.py
Class Name:
Method Name: test_iterative_saliency_refresh
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: e5b0e4f15d23be74d3bd34beb8e4a4b17634575b
Time: 2020-09-23
Author: killian.levacher@ibm.com
File Name: tests/attacks/evasion/test_frame_saliency.py
Class Name:
Method Name: test_iterative_saliency
Project Name: IBM/adversarial-robustness-toolbox
Commit Name: e5b0e4f15d23be74d3bd34beb8e4a4b17634575b
Time: 2020-09-23
Author: killian.levacher@ibm.com
File Name: tests/attacks/evasion/test_frame_saliency.py
Class Name:
Method Name: test_one_shot