secmlt.manipulations package
Submodules
secmlt.manipulations.manipulation module
Manipulations for perturbing input samples.
- class secmlt.manipulations.manipulation.AdditiveManipulation(domain_constraints: list[Constraint], perturbation_constraints: list[Constraint])[source]
Bases:
Manipulation
Additive manipulation for input data.
- class secmlt.manipulations.manipulation.Manipulation(domain_constraints: list[Constraint], perturbation_constraints: list[Constraint])[source]
Bases:
ABC
Abstract class for manipulations.
- __call__(x: torch.Tensor, delta: torch.Tensor) tuple[torch.Tensor, torch.Tensor] [source]
Apply the manipulation to the input data.
- Parameters:
x (torch.Tensor) – Input data.
delta (torch.Tensor) – Perturbation to apply.
- Returns:
Perturbed data and perturbation after the application of constraints.
- Return type:
tuple[torch.Tensor, torch.Tensor]
- __init__(domain_constraints: list[Constraint], perturbation_constraints: list[Constraint]) None [source]
Create manipulation object.
- Parameters:
domain_constraints (list[Constraint]) – Constraints for the domain bounds (x_adv).
perturbation_constraints (list[Constraint]) – Constraints for the perturbation (delta).
- abstract _apply_manipulation(x: torch.Tensor, delta: torch.Tensor) torch.Tensor [source]
Apply the manipulation.
- Parameters:
x (torch.Tensor) – Input samples.
delta (torch.Tensor) – Manipulation to apply.
- Returns:
Perturbed samples.
- Return type:
torch.Tensor
- property domain_constraints: list[Constraint]
Get the domain constraints for the manipulation.
- Returns:
List of domain constraints for the manipulation.
- Return type:
list[Constraint]
- property perturbation_constraints: list[Constraint]
Get the perturbation constraints for the manipulation.
- Returns:
List of perturbation constraints for the manipulation.
- Return type:
list[Constraint]
Module contents
Functionalities for applying manipulations to input data.