# Copyright 2019 Baidu Inc.
#
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and

"""Provides a class that represents an adversarial example
"""

import numpy as np
import numbers
from .base import StopAttack
from perceptron.utils.distances import MSE
from perceptron.utils.distances import Distance

"""Defines an adversarial that should be found and stores the result."""

def __init__(
self,
model,
criterion,
original_image,
original_pred,
threshold=None,
distance=MSE,
verbose=False):

model,
criterion,
original_image,
original_pred,
threshold,
distance,
verbose)

[docs]    def gradient(self, image=None, label=None, strict=True):

Parameters
----------
image : numpy.ndarray
Image with shape (height, width, channels).
Defaults to the original image.
label : int
Label used to calculate the loss that is differentiated.
Deefaults to the original label
strict : bool
Controls if the bounds for the pixel values should be checked.

"""
pass

self, image=None, annotation=None, strict=True, return_details=False):

Parameters
----------
image : numpy.ndarray
Image with shape (height, width, channels).
Defaults to the original image.
label : int
Label used to calculate the loss that is differentiated.
Defaults to the original label.
strict : bool
Controls if the bounds for the pixel values should be checked.

"""

if image is None:
image = self._original_image

assert not strict or self.in_bounds(image)

in_bounds = self.in_bounds(image)
assert not strict or in_bounds

self._total_prediction_calls += 1
image, predictions, in_bounds)

if return_details:
else: