• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bethgelab / foolbox / 8140123939

04 Mar 2024 12:25PM UTC coverage: 98.477%. Remained the same
8140123939

push

github

web-flow
Increase package version (#724)

3492 of 3546 relevant lines covered (98.48%)

7.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/foolbox/attacks/inversion.py
1
from typing import Union, Any, Optional
10✔
2
import eagerpy as ep
10✔
3

4
from ..criteria import Criterion
10✔
5

6
from ..models import Model
10✔
7

8
from .base import FlexibleDistanceMinimizationAttack
10✔
9
from .base import T
10✔
10
from .base import raise_if_kwargs
10✔
11
from .base import verify_input_bounds
10✔
12

13

14
class InversionAttack(FlexibleDistanceMinimizationAttack):
10✔
15
    """Creates "negative images" by inverting the pixel values. [#Hos16]_
16

17
    References:
18
        .. [#Hos16] Hossein Hosseini, Baicen Xiao, Mayoore Jaiswal, Radha Poovendran,
19
               "On the Limitation of Convolutional Neural Networks in Recognizing
20
               Negative Images",
21
               https://arxiv.org/abs/1607.02533
22
    """
23

24
    def run(
10✔
25
        self,
26
        model: Model,
27
        inputs: T,
28
        criterion: Union[Criterion, Any] = None,
29
        *,
30
        early_stop: Optional[float] = None,
31
        **kwargs: Any,
32
    ) -> T:
33
        raise_if_kwargs(kwargs)
8✔
34
        x, restore_type = ep.astensor_(inputs)
8✔
35
        del inputs, criterion, kwargs
8✔
36

37
        verify_input_bounds(x, model)
8✔
38

39
        min_, max_ = model.bounds
8✔
40
        x = min_ + max_ - x
8✔
41
        return restore_type(x)
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc