Projection Parameters

class dattri.params.projection.LoGraProjectionParams(*, proj_max_batch_size: int = 64, proj_seed: int = 0, proj_type: Literal['identity', 'normal', 'rademacher', 'sjlt', 'random_mask', 'grass'] = 'normal', proj_dim_per_layer: int = 4096)

Projection params for LoGra attributor.

Parameters:
  • proj_dim_per_layer (int) – Dimension of the projected feature per layer.

  • proj_max_batch_size (int) – The maximum batch size if the CudaProjector is used. Must be a multiple of 8. The maximum batch size is 32 for A100 GPUs, 16 for V100 GPUs, 40 for H100 GPUs.

  • proj_seed (int) – Random seed used by the projector. Defaults to 0.

  • (Literal["identity" (proj_type)

  • "normal"

  • "rademacher"

  • "sjlt"

:param : :param “random_mask”: The random projection type used for the projection. :param “grass”]): The random projection type used for the projection.

class dattri.params.projection.TracInProjectionParams(*, proj_max_batch_size: int = 32, proj_seed: int = 0, proj_type: Literal['identity', 'normal', 'rademacher', 'sjlt', 'random_mask', 'grass'] = 'normal', proj_dim: int = 512)

Projection params for TracIn attributor.

Parameters:
  • proj_dim (int) – Dimension of the projected feature.

  • proj_max_batch_size (int) – The maximum batch size if the CudaProjector is used. Must be a multiple of 8. The maximum batch size is 32 for A100 GPUs, 16 for V100 GPUs, 40 for H100 GPUs.

  • proj_seed (int) – Random seed used by the projector. Defaults to 0.

  • (Literal["identity" (proj_type)

  • "normal"

  • "rademacher"

  • "sjlt"

:param : :param “random_mask”: The random projection type used for the projection. :param “grass”]): The random projection type used for the projection.

class dattri.params.projection.TRAKProjectionParams(*, proj_max_batch_size: int = 32, proj_seed: int = 0, proj_type: Literal['identity', 'normal', 'rademacher', 'sjlt', 'random_mask', 'grass'] = 'normal', proj_dim: int = 512)

Projection params for TRAK attributor.

Parameters:
  • proj_dim (int) – Dimension of the projected feature.

  • proj_max_batch_size (int) – The maximum batch size if the CudaProjector is used. Must be a multiple of 8. The maximum batch size is 32 for A100 GPUs, 16 for V100 GPUs, 40 for H100 GPUs.

  • proj_seed (int) – Random seed used by the projector. Defaults to 0.

  • (Literal["identity" (proj_type)

  • "normal"

  • "rademacher"

  • "sjlt"

:param : :param “random_mask”: The random projection type used for the projection. :param “grass”]): The random projection type used for the projection.

class dattri.params.projection.DVEmbProjectionParams(*, proj_max_batch_size: int = 64, proj_seed: int = 0, proj_type: Literal['identity', 'normal', 'rademacher', 'sjlt', 'random_mask', 'grass'] = 'identity', proj_dim_per_layer: int | None = None)

Projection params for DVEmb; proj_dim_per_layer can be None for no projection.

Parameters:
  • proj_dim_per_layer (int) – Dimension of the projected feature per layer.

  • proj_max_batch_size (int) – The maximum batch size if the CudaProjector is used. Must be a multiple of 8. The maximum batch size is 32 for A100 GPUs, 16 for V100 GPUs, 40 for H100 GPUs.

  • proj_seed (int) – Random seed used by the projector. Defaults to 0.

  • (Literal["identity" (proj_type)

  • "normal"

  • "rademacher"

  • "sjlt"

:param : :param “random_mask”: The random projection type used for the projection. :param “grass”]): The random projection type used for the projection.

class dattri.params.projection.RandomProjectionParams(*, proj_max_batch_size: int, proj_seed: int, proj_type: Literal['identity', 'normal', 'rademacher', 'sjlt', 'random_mask', 'grass'] = 'normal', proj_dim: int, feature_batch_size: int, device: device)

Params for random_project().

Parameters:
  • proj_dim (int) – Dimension of the projected feature.

  • proj_max_batch_size (int) – The maximum batch size if the CudaProjector is used. Must be a multiple of 8. The maximum batch size is 32 for A100 GPUs, 16 for V100 GPUs, 40 for H100 GPUs.

  • proj_seed (int) – Random seed used by the projector. Defaults to 0.

  • feature_batch_size (int) – The batch size of each tensor in the feature about to be projected. The typical type of feature are gradients of torch.nn.Module model but can be restricted to this.

  • device (torch.device) – Device to use. Defaults to cpu.

  • (Literal["identity" (proj_type)

  • "normal"

  • "rademacher"

  • "sjlt"

:param : :param “random_mask”: The random projection type used for the projection. :param “grass”]): The random projection type used for the projection. :param device: “cuda” or “cpu”. Defaults to “cpu”. :type device: Union[str, torch.device]