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

bethgelab / foolbox / 8139141456

04 Mar 2024 11:03AM UTC coverage: 37.923% (-60.6%) from 98.477%
8139141456

Pull #722

github

web-flow
Merge 5663238db into 17e0e9b31
Pull Request #722: Fix guide compilation

1344 of 3544 relevant lines covered (37.92%)

0.38 hits per line

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

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

4
from ..criteria import Criterion
1✔
5

6
from ..models import Model
1✔
7

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

13

14
class InversionAttack(FlexibleDistanceMinimizationAttack):
1✔
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(
1✔
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)
×
34
        x, restore_type = ep.astensor_(inputs)
×
35
        del inputs, criterion, kwargs
×
36

37
        verify_input_bounds(x, model)
×
38

39
        min_, max_ = model.bounds
×
40
        x = min_ + max_ - x
×
41
        return restore_type(x)
×
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