Click4Ai

492.

Hard

Adversarial Examples

=======================

In this problem, you will create a function to generate adversarial examples for 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 create an adversarial example for 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 adversarial example should be a 3D numpy array with the same shape as the input image.
  • The model's output for the adversarial example should be different from its output for the original input image.
  • 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