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#

class aijack.attack.inversion.utils.datarepextractor.DataRepExtractor(net, num_fc_layers=1, m=1, bias=True)[source]#

Bases: object

extract_datarep(dldw)[source]#
get_dldw(loss)[source]#

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

aijack.attack.inversion.utils.regularization.label_matching(pred, label)[source]#

Computes the label matching loss between predicted and target labels.

Parameters
  • pred (torch.Tensor) – Predicted labels.

  • label (torch.Tensor) – Target labels.

Returns

The label matching loss.

Return type

torch.Tensor

aijack.attack.inversion.utils.regularization.total_variance(x)[source]#

Computes the total variance of an input tensor.

Parameters

x (torch.Tensor) – The input tensor.

Returns

The total variance.

Return type

torch.Tensor

1.1.4.1.1.5. aijack.attack.inversion.utils.utils module#

1.1.4.1.1.6. Module contents#