Click4Ai

494.

Hard

PGD Attack

==========

In this problem, you will create a function to perform a projected gradient descent (PGD) attack on a given input image and model.

Example:

Suppose we have an image classification model that classifies images into two categories: cats and dogs. We want to perform a PGD attack on an input image of a cat that will be misclassified as a dog.

Constraints:

  • The input image is a 3D numpy array with shape (height, width, channels).
  • The model is a pre-trained neural network with a fixed architecture.
  • The attack should be performed with an epsilon value of 0.1 and a step size of 0.01.
  • Test Cases

    Test Case 1
    Input: [[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]
    Expected: [[[0, 0, 0], [0, 0, 0], [0, 0, 0]]]
    Test Case 2
    Input: [[[255, 255, 255], [255, 255, 255], [255, 255, 255]]]
    Expected: [[[255, 255, 255], [255, 255, 255], [255, 255, 255]]]
    + 3 hidden test cases