advsecurenet.shared.types.configs package



advsecurenet.shared.types.configs.configs module

class advsecurenet.shared.types.configs.configs.ConfigType(value)

Bases: Enum

Enum for configuration types that can be loaded in the CLI.

ADVERSARIAL_EVALUATION = 'adversarial_evaluation'
ADVERSARIAL_TRAINING = 'adversarial_training'
ATTACK = 'attack'
DATASET = 'dataset'
DEFENSE = 'defense'
EVALUATION = 'evaluation'
MODEL = 'model'
TEST = 'test'
TRAIN = 'train'

advsecurenet.shared.types.configs.dataloader_config module

class advsecurenet.shared.types.configs.dataloader_config.DataLoaderConfig(dataset: BaseDataset, batch_size: int | None = 16, num_workers: int | None = 4, shuffle: bool | None = True, sampler: DistributedSampler | None = None, pin_memory: bool | None = True, drop_last: bool | None = False)

Bases: object

This dataclass is used to store the configuration of the data loader.

batch_size: int | None = 16
dataset: BaseDataset
drop_last: bool | None = False
num_workers: int | None = 4
pin_memory: bool | None = True
sampler: DistributedSampler | None = None
shuffle: bool | None = True

advsecurenet.shared.types.configs.device_config module

class advsecurenet.shared.types.configs.device_config.DeviceConfig(use_ddp: bool | None = False, processor: str | None = 'cpu', gpu_ids: str | None = None)

Bases: object

This dataclass is used to store the configuration of the device.

gpu_ids: str | None = None
processor: str | None = 'cpu'
use_ddp: bool | None = False

advsecurenet.shared.types.configs.model_config module

class advsecurenet.shared.types.configs.model_config.BaseModelConfig(*, model_name: str, num_classes: int | None = 1000, num_input_channels: int | None = 3, pretrained: bool | None = False)

Bases: object

Base configuration class for different model configurations.

model_name: str
num_classes: int | None = 1000
num_input_channels: int | None = 3
pretrained: bool | None = False
class advsecurenet.shared.types.configs.model_config.CreateModelConfig(model_arch_path: str | None = None, model_weights_path: str | None = None, custom_models_path: str | None = 'CustomModels', weights: str | None = 'IMAGENET1K_V1', is_external: bool = False, random_seed: int | None = None, *, model_name: str, num_classes: int | None = 1000, num_input_channels: int | None = 3, pretrained: bool | None = False)

Bases: StandardModelConfig, CustomModelConfig, ExternalModelConfig

Config parameters for creating a model in the model factory.

is_external: bool = False
random_seed: int | None = None
class advsecurenet.shared.types.configs.model_config.CustomModelConfig(custom_models_path: str | None = 'CustomModels', *, model_name: str, num_classes: int | None = 1000, num_input_channels: int | None = 3, pretrained: bool | None = False)

Bases: BaseModelConfig

Configuration for a custom model.

custom_models_path: str | None = 'CustomModels'
class advsecurenet.shared.types.configs.model_config.ExternalModelConfig(model_arch_path: str | None = None, model_weights_path: str | None = None, *, model_name: str, num_classes: int | None = 1000, num_input_channels: int | None = 3, pretrained: bool | None = False)

Bases: BaseModelConfig

Configuration for an external model.

model_arch_path: str | None = None
model_weights_path: str | None = None
class advsecurenet.shared.types.configs.model_config.StandardModelConfig(weights: str | None = 'IMAGENET1K_V1', *, model_name: str, num_classes: int | None = 1000, num_input_channels: int | None = 3, pretrained: bool | None = False)

Bases: BaseModelConfig

Configuration for a standard model.

weights: str | None = 'IMAGENET1K_V1'

advsecurenet.shared.types.configs.preprocess_config module

class advsecurenet.shared.types.configs.preprocess_config.PreprocessConfig(steps: list[PreprocessStep] | None = None)

Bases: object

This dataclass is used to store the configuration of the preprocessing pipeline.

steps: list[PreprocessStep] | None = None
class advsecurenet.shared.types.configs.preprocess_config.PreprocessStep(name: str, params: dict | None = None)

Bases: object

This dataclass is used to store the configuration of a preprocessing step.

name: str
params: dict | None = None

advsecurenet.shared.types.configs.test_config module

class advsecurenet.shared.types.configs.test_config.TestConfig(model: BaseModel, test_loader: DataLoader, criterion: str | Module = 'cross_entropy', processor: device | None = device(type='cpu'), topk: int = 1)

Bases: object

This dataclass is used to store the configuration of the test CLI.

criterion: str | Module = 'cross_entropy'
model: BaseModel
processor: device | None = device(type='cpu')
test_loader: DataLoader
topk: int = 1

advsecurenet.shared.types.configs.train_config module

class advsecurenet.shared.types.configs.train_config.CheckpointConfig(save_checkpoint: bool = False, save_checkpoint_path: str | None = None, save_checkpoint_name: str | None = None, checkpoint_interval: int = 1, load_checkpoint: bool = False, load_checkpoint_path: str | None = None)

Bases: object

Configuration class for the checkpoint.

checkpoint_interval: int = 1
load_checkpoint: bool = False
load_checkpoint_path: str | None = None
save_checkpoint: bool = False
save_checkpoint_name: str | None = None
save_checkpoint_path: str | None = None
class advsecurenet.shared.types.configs.train_config.FinalModelConfig(save_final_model: bool = False, save_model_path: str | None = None, save_model_name: str | None = None)

Bases: object

Configuration class for the final model.

save_final_model: bool = False
save_model_name: str | None = None
save_model_path: str | None = None
class advsecurenet.shared.types.configs.train_config.ModelConfig(model: Module | None = None)

Bases: object

Configuration class for the model.

model: Module = None
class advsecurenet.shared.types.configs.train_config.OptimizationConfig(optimizer: str | Optimizer = 'adam', optimizer_kwargs: dict | None = None, scheduler: str | Module | None = None, scheduler_kwargs: dict | None = None)

Bases: object

Configuration class for the optimization process.

optimizer: str | Optimizer = 'adam'
optimizer_kwargs: dict | None = None
scheduler: str | Module | None = None
scheduler_kwargs: dict | None = None
class advsecurenet.shared.types.configs.train_config.TrainConfig(use_ddp: bool | None = False, processor: str | None = 'cpu', gpu_ids: str | None = None, save_final_model: bool = False, save_model_path: str | None = None, save_model_name: str | None = None, save_checkpoint: bool = False, save_checkpoint_path: str | None = None, save_checkpoint_name: str | None = None, checkpoint_interval: int = 1, load_checkpoint: bool = False, load_checkpoint_path: str | None = None, optimizer: str | Optimizer = 'adam', optimizer_kwargs: dict | None = None, scheduler: str | Module | None = None, scheduler_kwargs: dict | None = None, train_loader: DataLoader | None = None, criterion: str | Module = 'cross_entropy', epochs: int = 10, learning_rate: float = 0.001, verbose: bool = False, model: Module | None = None)

Bases: ModelConfig, TrainingProcessConfig, OptimizationConfig, CheckpointConfig, FinalModelConfig, DeviceConfig

Dataclass to store the overall training configuration by aggregating other configurations.

class advsecurenet.shared.types.configs.train_config.TrainingProcessConfig(train_loader: DataLoader | None = None, criterion: str | Module = 'cross_entropy', epochs: int = 10, learning_rate: float = 0.001, verbose: bool = False)

Bases: object

Configuration class for the training process.

criterion: str | Module = 'cross_entropy'
epochs: int = 10
learning_rate: float = 0.001
train_loader: DataLoader = None
verbose: bool = False