1.1.4.1.1. aijack.attack.inversion.utils package#
1.1.4.1.1.1. Submodules#
1.1.4.1.1.2. aijack.attack.inversion.utils.datarepextractor module#
1.1.4.1.1.3. aijack.attack.inversion.utils.distance module#
- aijack.attack.inversion.utils.distance.cossim(fake_gradients, received_gradients, gradient_ignore_pos)[source]#
Computes the cosine similarity distance between fake and received gradients.
- Parameters
fake_gradients (list of torch.Tensor) – List of fake gradients.
received_gradients (list of torch.Tensor) – List of received gradients.
gradient_ignore_pos (list of int) – Positions to ignore while computing distance.
- Returns
The cosine similarity distance.
- Return type
float
- aijack.attack.inversion.utils.distance.l2(fake_gradients, received_gradients, gradient_ignore_pos)[source]#
Computes the L2 distance between fake and received gradients.
- Parameters
fake_gradients (list of torch.Tensor) – List of fake gradients.
received_gradients (list of torch.Tensor) – List of received gradients.
gradient_ignore_pos (list of int) – Positions to ignore while computing distance.
- Returns
The L2 distance.
- Return type
float
1.1.4.1.1.4. aijack.attack.inversion.utils.regularization module#
- aijack.attack.inversion.utils.regularization.bn_regularizer(feature_maps, bn_layers)[source]#
Computes the batch normalization regularizer loss.
- Parameters
feature_maps (list) – List of feature maps.
bn_layers (list) – List of batch normalization layers.
- Returns
The batch normalization regularizer loss.
- Return type
torch.Tensor
- aijack.attack.inversion.utils.regularization.group_consistency(x, group_x)[source]#
Computes the group consistency loss between an input and a group of inputs.
- Parameters
x (torch.Tensor) – The input tensor.
group_x (list) – List of tensors representing the group.
- Returns
The group consistency loss.
- Return type
torch.Tensor