Esempio n. 1
0
class TrainingConfing(TrainingConfigBase):

    lib_dir = lib_dir

    num_epochs = 40
    val_interval = 1
    weight_decay = 5e-4

    inner_iters = 10
    K = 5
    sigma = 0.01
    eps = 0.3

    create_optimizer = SGDOptimizerMaker(lr=1e-2 / K,
                                         momentum=0.9,
                                         weight_decay=weight_decay)
    create_lr_scheduler = PieceWiseConstantLrSchedulerMaker(
        milestones=[30, 35, 39], gamma=0.1)

    create_loss_function = None

    # create_attack_method = None

    create_attack_method = \
        IPGDAttackMethodMaker(eps = 0.3, sigma = 0.01, nb_iters = 40, norm = np.inf,
                              mean = torch.tensor(np.array([0]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]),
                              std = torch.tensor(np.array([1]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]))

    create_evaluation_attack_method = \
        IPGDAttackMethodMaker(eps = 0.3, sigma = 0.01, nb_iters = 40, norm = np.inf,
                              mean=torch.tensor(
                                  np.array([0]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]),
                              std=torch.tensor(np.array([1]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]))
class TrainingConfing(TrainingConfigBase):

    lib_dir = lib_dir

    num_epochs = 105
    val_interval = 5

    create_optimizer = SGDOptimizerMaker(lr=5e-2,
                                         momentum=0.9,
                                         weight_decay=5e-4)
    create_lr_scheduler = PieceWiseConstantLrSchedulerMaker(
        milestones=[75, 90, 100], gamma=0.1)

    create_loss_function = torch.nn.CrossEntropyLoss

    create_attack_method = \
        IPGDAttackMethodMaker(eps = 8/255.0, sigma = 2/255.0, nb_iters = 10, norm = np.inf,
                              mean = torch.tensor(np.array([0]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]),
                              std = torch.tensor(np.array([1]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]))

    create_evaluation_attack_method = \
        IPGDAttackMethodMaker(eps = 8/255.0, sigma = 2/255.0, nb_iters = 20, norm = np.inf,
                              mean=torch.tensor(
                                  np.array([0]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]),
                              std=torch.tensor(np.array([1]).astype(np.float32)[np.newaxis, :, np.newaxis, np.newaxis]))
Esempio n. 3
0
class TrainingConfing(TrainingConfigBase):

    lib_dir = lib_dir

    num_epochs = 10
    val_interval = 2

    create_optimizer = SGDOptimizerMaker(lr=1e-1,
                                         momentum=0.9,
                                         weight_decay=1e-3)
    create_lr_scheduler = PieceWiseConstantLrSchedulerMaker(
        milestones=[5, 7, 9], gamma=0.1)

    create_loss_function = torch.nn.CrossEntropyLoss