80cfb0e5f889c65a972ebde6c6dae4278b5e28c1,foolbox/attacks/base.py,MinimizationAttack,__call__,#MinimizationAttack#Any#Any#Any#,340

Before Change



        was_iterable = True
        if not isinstance(epsilons, Iterable):
            epsilons = [epsilons]
            was_iterable = False

        N = len(x)
        K = len(epsilons)

        // None means: just minimize, no early stopping, no limit on the perturbation size
        if any(eps is None for eps in epsilons):
            early_stop = None
        else:
            early_stop = min(epsilons)
        limit_epsilons = [eps if eps is not None else ep.inf for eps in epsilons]
        del epsilons

        // run the actual attack
        xp = self.run(model, x, criterion, early_stop=early_stop, **kwargs)
        // TODO: optionally improve using a binary search?
        // TODO: optionally reduce size to the different epsilons and recompute is_adv

        is_adv = is_adversarial(xp)
        assert is_adv.shape == (N,)

        distances = self.distance(x, xp)
        assert distances.shape == (N,)

        in_limits = ep.stack(
            [distances <= epsilon for epsilon in limit_epsilons], axis=0
        )
        assert in_limits.shape == (K, N)

        success = ep.logical_and(in_limits, is_adv)
        assert success.shape == (K, N)

        xp_ = restore_type(xp)

After Change


            xpcs.append(xpc)
            success.append(is_adv)

        success_ = ep.stack(success)
        assert success_.shape == (K, N)

        xp_ = restore_type(xp)
        xpcs_ = [restore_type(xpc) for xpc in xpcs]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 8

Instances


Project Name: bethgelab/foolbox
Commit Name: 80cfb0e5f889c65a972ebde6c6dae4278b5e28c1
Time: 2020-02-14
Author: git@jonasrauber.de
File Name: foolbox/attacks/base.py
Class Name: MinimizationAttack
Method Name: __call__


Project Name: astorfi/TensorFlow-World
Commit Name: 874382bfb96b92dcfdd6326ba83c54ad1e9d42f2
Time: 2017-06-26
Author: amirsina.torfi@gmail.com
File Name: codes/2-basics_in_machine_learning/linear_regression/code/linear_regression.py
Class Name:
Method Name:


Project Name: pytorch/examples
Commit Name: 7ee5c4cc9f2224f24f8121e78fdc969a2bf754e1
Time: 2017-01-11
Author: alerer@fb.com
File Name: OpenNMT/onmt/Models.py
Class Name: Decoder
Method Name: forward