メインコンテンツ

AdversarialOptionsFGSM

Options for generating adversarial examples using the fast gradient sign method (FGSM)

Since R2026a

    Description

    Add-On Required: This feature requires the AI Verification Library for Deep Learning Toolbox add-on.

    Use an AdversarialOptionsFGSM object to set adversarial options for the FGSM (fast gradient sign method) algorithm, including step size, execution environment, and mini-batch size.

    Creation

    Create an AdversarialOptionsFGSM object using adversarialOptions and specifying "fgsm" as the first input argument.

    Properties

    expand all

    Size of mini-batches to use for generating adversarial examples, specified as a positive integer. Larger mini-batch sizes require more memory, but can lead to faster performance.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Hardware resource for generating adversarial examples, specified as one of these values:

    • "auto" – Use a local GPU if one is available. Otherwise, use the local CPU.

    • "cpu" – Use the local CPU.

    • "gpu" – Use the local GPU.

    • "multi-gpu" – Use multiple GPUs on one machine, using a local parallel pool based on your default cluster profile. If there is no current parallel pool, the software starts a parallel pool with pool size equal to the number of available GPUs.

    • "parallel-auto" – Use a local or remote parallel pool. If there is no current parallel pool, the software starts one using the default cluster profile. If the pool has access to GPUs, then only workers with a unique GPU perform training computation and excess workers become idle. If the pool does not have GPUs, then training takes place on all available CPU workers instead.

    • "parallel-cpu" – Use CPU resources in a local or remote parallel pool, ignoring any GPUs. If there is no current parallel pool, the software starts one using the default cluster profile.

    • "parallel-gpu" – Use GPUs in a local or remote parallel pool. Excess workers become idle. If there is no current parallel pool, the software starts one using the default cluster profile.

    The "gpu", "multi-gpu", "parallel-auto", "parallel-cpu", and "parallel-gpu" options require Parallel Computing Toolbox™. To use a GPU for deep learning, you must also have a supported GPU device. For information on supported devices, see GPU Computing Requirements (Parallel Computing Toolbox). If you choose one of these options and Parallel Computing Toolbox or a suitable GPU is not available, then the software returns an error.

    For more information on when to use the different execution environments, see Scale Up Deep Learning in Parallel, on GPUs, and in the Cloud.

    Step size used to generate adversarial examples, specified as a positive scalar.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Option to enable verbose output, specified as a numeric or logical 1 (true) or 0 (false). When you set this input to 1 (true), the function returns its progress by indicating which mini-batch the function is processing and the total number of mini-batches. The function also returns the amount of time computation takes.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

    Examples

    collapse all

    Create a set of options for finding adversarial examples using the FGSM algorithm. Set the step size to 20 and the mini-batch size to 64.

    options = adversarialOptions("fgsm",StepSize=20,MiniBatchSize=64)
    options = 
      AdversarialOptionsFGSM with properties:
    
                    StepSize: 20
               MiniBatchSize: 64
        ExecutionEnvironment: 'auto'
                     Verbose: 0
    
    

    Version History

    Introduced in R2026a