Exemplo n.º 1
0
def run_jsma(weight_fpath):
    flags.DEFINE_boolean('viz_enabled', VIZ_ENABLED,
                         'Visualize adversarial ex.')
    flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                         'Number of epochs to train model')
    flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
    flags.DEFINE_integer('source_samples', SOURCE_SAMPLES,
                         'Nb of test inputs to attack')
    flags.DEFINE_float('learning_rate', LEARNING_RATE,
                       'Learning rate for training')

    mnist_tutorial_jsma(weight_fpath,
                        viz_enabled=FLAGS.viz_enabled,
                        nb_epochs=FLAGS.nb_epochs,
                        batch_size=FLAGS.batch_size,
                        source_samples=FLAGS.source_samples,
                        learning_rate=FLAGS.learning_rate)
Exemplo n.º 2
0
def run_black_box(weight_fpath, FGSM):

  # General flags
  flags.DEFINE_integer('nb_classes', NB_CLASSES,
                       'Number of classes in problem')
  flags.DEFINE_integer('batch_size', BATCH_SIZE,
                       'Size of training batches')
  flags.DEFINE_float('learning_rate', LEARNING_RATE,
                     'Learning rate for training')

  # Flags related to oracle
  flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                       'Number of epochs to train model')

  # Flags related to substitute
  flags.DEFINE_integer('holdout', HOLDOUT,
                       'Test set holdout for adversary')
  flags.DEFINE_integer('data_aug', DATA_AUG,
                       'Number of substitute data augmentations')
  flags.DEFINE_integer('nb_epochs_s', NB_EPOCHS_S,
                       'Training epochs for substitute')
  flags.DEFINE_float('lmbda', LMBDA, 'Lambda from arxiv.org/abs/1602.02697')
  flags.DEFINE_integer('data_aug_batch_size', AUG_BATCH_SIZE,
                       'Batch size for augmentation')

  mnist_blackbox(FGSM, weight_fpath, nb_classes=FLAGS.nb_classes, batch_size=FLAGS.batch_size,
                 learning_rate=FLAGS.learning_rate,
                 nb_epochs=FLAGS.nb_epochs, holdout=FLAGS.holdout,
                 data_aug=FLAGS.data_aug, nb_epochs_s=FLAGS.nb_epochs_s,
                 lmbda=FLAGS.lmbda, aug_batch_size=FLAGS.data_aug_batch_size)

  #tf.app.run()



#Write about customized weights for paper
#Do we want to perform attacks against samples from y_sub? No right?

#Multi agent attacking
#Corrupt agent follows normal policy - if the state is worth attacking then attack the good agent
#Paper - tactics of adversarial attacks on deep reinforcement learning agents (for white box)
#Assuming black box
#Formulate the problem mathematically
Exemplo n.º 3
0
  check_installation(__file__)

  mnist_tutorial_fgsm(viz_enabled=FLAGS.viz_enabled,
                    nb_epochs=FLAGS.nb_epochs,
                    batch_size=FLAGS.batch_size,
                    source_samples=FLAGS.source_samples,
                    learning_rate=FLAGS.learning_rate,
                    attack_iterations=FLAGS.attack_iterations,
                    model_path=FLAGS.model_path,
                    targeted=FLAGS.targeted)


if __name__ == '__main__':
  flags.DEFINE_boolean('viz_enabled', VIZ_ENABLED,
                       'Visualize adversarial ex.')
  flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                       'Number of epochs to train model')
  flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
  flags.DEFINE_integer('source_samples', SOURCE_SAMPLES,
                       'Number of test inputs to attack')
  flags.DEFINE_float('learning_rate', LEARNING_RATE,
                     'Learning rate for training')
  flags.DEFINE_string('model_path', MODEL_PATH,
                      'Path to save or load the model file')
  flags.DEFINE_integer('attack_iterations', ATTACK_ITERATIONS,
                       'Number of iterations to run attack; 1000 is good')
  flags.DEFINE_boolean('targeted', TARGETED,
                       'Run the tutorial in targeted mode?')

  tf.app.run()
    bim_test = np.expand_dims(bim_test, axis=3)
    bim_test_decoded = model.predict(bim_test)
    eval(bim_test)
    eval(bim_test_decoded)


def main(argv=None):
    from cleverhans_tutorials import check_installation
    check_installation(__file__)

    mnist_tutorial(nb_epochs=FLAGS.nb_epochs,
                   batch_size=FLAGS.batch_size,
                   learning_rate=FLAGS.learning_rate,
                   train_dir=FLAGS.train_dir,
                   filename=FLAGS.filename,
                   load_model=FLAGS.load_model)


if __name__ == '__main__':
    flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                         'Number of epochs to train model')
    flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
    flags.DEFINE_float('learning_rate', LEARNING_RATE,
                       'Learning rate for training')
    flags.DEFINE_string('train_dir', TRAIN_DIR,
                        'Directory where to save model.')
    flags.DEFINE_string('filename', FILENAME, 'Checkpoint filename.')
    flags.DEFINE_boolean('load_model', LOAD_MODEL,
                         'Load saved model or train.')
    tf.app.run()
Exemplo n.º 5
0
        raise ValueError(argv)
    make_confidence_report(filepath=filepath,
                           test_start=FLAGS.test_start,
                           test_end=FLAGS.test_end,
                           which_set=FLAGS.which_set,
                           report_path=FLAGS.report_path,
                           mc_batch_size=FLAGS.mc_batch_size,
                           nb_iter=FLAGS.nb_iter,
                           base_eps_iter=FLAGS.base_eps_iter,
                           batch_size=FLAGS.batch_size,
                           save_advx=FLAGS.save_advx)


if __name__ == '__main__':
    flags.DEFINE_integer(
        'train_start', TRAIN_START, 'Starting point (inclusive)'
        'of range of train examples to use')
    flags.DEFINE_integer(
        'train_end', TRAIN_END, 'Ending point (non-inclusive) '
        'of range of train examples to use')
    flags.DEFINE_integer(
        'test_start', TEST_START, 'Starting point (inclusive) '
        'of range of test examples to use')
    flags.DEFINE_integer(
        'test_end', TEST_END, 'End point (non-inclusive) of '
        'range of test examples to use')
    flags.DEFINE_integer('nb_iter', NB_ITER, 'Number of iterations of PGD')
    flags.DEFINE_string('which_set', WHICH_SET, '"train" or "test"')
    flags.DEFINE_string('report_path', REPORT_PATH, 'Path to save to')
    flags.DEFINE_integer('mc_batch_size', MC_BATCH_SIZE,
                         'Batch size for MaxConfidence')
Exemplo n.º 6
0
        _name_of_script, filepath = argv
    except ValueError:
        raise ValueError(argv)
    make_confidence_report_spsa(filepath=filepath,
                                test_start=FLAGS.test_start,
                                test_end=FLAGS.test_end,
                                which_set=FLAGS.which_set,
                                report_path=FLAGS.report_path,
                                nb_iter=FLAGS.nb_iter,
                                batch_size=FLAGS.batch_size,
                                spsa_samples=FLAGS.spsa_samples,
                                spsa_iters=FLAGS.spsa_iters)


if __name__ == '__main__':
    flags.DEFINE_integer('spsa_samples', SPSA_SAMPLES,
                         'Number samples for SPSA')
    flags.DEFINE_integer('spsa_iters', SPSA.DEFAULT_SPSA_ITERS,
                         'Passed to SPSA.generate')
    flags.DEFINE_integer(
        'train_start', TRAIN_START, 'Starting point (inclusive)'
        'of range of train examples to use')
    flags.DEFINE_integer(
        'train_end', TRAIN_END, 'Ending point (non-inclusive) '
        'of range of train examples to use')
    flags.DEFINE_integer(
        'test_start', TEST_START, 'Starting point (inclusive) of range'
        ' of test examples to use')
    flags.DEFINE_integer(
        'test_end', TEST_END, 'End point (non-inclusive) of range'
        ' of test examples to use')
    flags.DEFINE_integer('nb_iter', NB_ITER_SPSA,
Exemplo n.º 7
0
    return report


def main(argv=None):
    from cleverhans_tutorials import check_installation

    check_installation(__file__)

    mnist_tutorial_jsma(
        viz_enabled=FLAGS.viz_enabled,
        nb_epochs=FLAGS.nb_epochs,
        batch_size=FLAGS.batch_size,
        source_samples=FLAGS.source_samples,
        learning_rate=FLAGS.learning_rate,
    )


if __name__ == "__main__":
    flags.DEFINE_boolean("viz_enabled", VIZ_ENABLED,
                         "Visualize adversarial ex.")
    flags.DEFINE_integer("nb_epochs", NB_EPOCHS,
                         "Number of epochs to train model")
    flags.DEFINE_integer("batch_size", BATCH_SIZE, "Size of training batches")
    flags.DEFINE_integer("source_samples", SOURCE_SAMPLES,
                         "Nb of test inputs to attack")
    flags.DEFINE_float("learning_rate", LEARNING_RATE,
                       "Learning rate for training")

    tf.app.run()
Exemplo n.º 8
0
    import matplotlib.pyplot as plt
    plt.close(figure)
    _ = grid_visual(grid_viz_data)

  return report


def main(argv=None):
  from cleverhans_tutorials import check_installation
  check_installation(__file__)

  mnist_tutorial_jsma(viz_enabled=FLAGS.viz_enabled,
                      nb_epochs=FLAGS.nb_epochs,
                      batch_size=FLAGS.batch_size,
                      source_samples=FLAGS.source_samples,
                      learning_rate=FLAGS.learning_rate)


if __name__ == '__main__':
  flags.DEFINE_boolean('viz_enabled', VIZ_ENABLED,
                       'Visualize adversarial ex.')
  flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                       'Number of epochs to train model')
  flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
  flags.DEFINE_integer('source_samples', SOURCE_SAMPLES,
                       'Nb of test inputs to attack')
  flags.DEFINE_float('learning_rate', LEARNING_RATE,
                     'Learning rate for training')

  tf.app.run()
Exemplo n.º 9
0
    try:
        _name_of_script, filepath = argv
    except ValueError:
        raise ValueError(argv)
    print_accuracies(filepath=filepath,
                     test_start=FLAGS.test_start,
                     test_end=FLAGS.test_end,
                     which_set=FLAGS.which_set,
                     nb_iter=FLAGS.nb_iter,
                     base_eps_iter=FLAGS.base_eps_iter,
                     batch_size=FLAGS.batch_size)


if __name__ == '__main__':
    flags.DEFINE_integer(
        'train_start', TRAIN_START, 'Starting point (inclusive)'
        'of range of train examples to use')
    flags.DEFINE_integer(
        'train_end', TRAIN_END, 'Ending point (non-inclusive) '
        'of range of train examples to use')
    flags.DEFINE_integer(
        'test_start', TEST_START, 'Starting point (inclusive) '
        'of range of test examples to use')
    flags.DEFINE_integer(
        'test_end', TEST_END, 'End point (non-inclusive) of '
        'range of test examples to use')
    flags.DEFINE_integer('nb_iter', NB_ITER, 'Number of iterations of PGD')
    flags.DEFINE_string('which_set', WHICH_SET, '"train" or "test"')
    flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Batch size for most jobs')
    flags.DEFINE_float('base_eps_iter', BASE_EPS_ITER,
                       'epsilon per iteration, if data were in [0, 1]')
Exemplo n.º 10
0
  check_installation(__file__)

  train_deflecting(dataset_name=FLAGS.dataset, 
                   train_end=FLAGS.train_end, 
                   test_end=FLAGS.test_end, 
                   nb_epochs=FLAGS.nb_epochs, 
                   batch_size=FLAGS.batch_size, 
                   num_capsules_output=FLAGS.num_capsules_output, 
                   output_atoms=FLAGS.output_atoms,
                   num_routing=FLAGS.num_routing,
                   learning_rate=FLAGS.learning_rate,
                   nb_filters=FLAGS.nb_filters)


if __name__ == '__main__':  
  flags.DEFINE_integer('train_end', TRAIN_END,
                       'Number of training data')
  flags.DEFINE_integer('test_end', TEST_END,
                       'Number of test data')
  flags.DEFINE_integer('nb_filters', NB_FILTERS,
                       'Model size multiplier')
  flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                       'Number of epochs to train model')
  flags.DEFINE_integer('batch_size', BATCH_SIZE,
                       'Size of training batches')
  flags.DEFINE_integer('num_capsules_output', NUM_CAPSULES_OUTPUT,
                       'Number of class capsules and background capsules')
  flags.DEFINE_integer('output_atoms', OUTPUT_ATOMS,
                       'Size of each capsule')
  flags.DEFINE_integer('num_routing', NUM_ROUTING,
                       'Number of routing in capsule layer')
  flags.DEFINE_float('learning_rate', LEARNING_RATE,
Exemplo n.º 11
0
    mnist_tutorial_cw(
        viz_enabled=FLAGS.viz_enabled,
        nb_epochs=FLAGS.nb_epochs,
        batch_size=FLAGS.batch_size,
        source_samples=FLAGS.source_samples,
        learning_rate=FLAGS.learning_rate,
        attack_iterations=FLAGS.attack_iterations,
        model_path=FLAGS.model_path,
        targeted=FLAGS.targeted,
    )


if __name__ == "__main__":
    flags.DEFINE_boolean("viz_enabled", VIZ_ENABLED, "Visualize adversarial ex.")
    flags.DEFINE_integer("nb_epochs", NB_EPOCHS, "Number of epochs to train model")
    flags.DEFINE_integer("batch_size", BATCH_SIZE, "Size of training batches")
    flags.DEFINE_integer(
        "source_samples", SOURCE_SAMPLES, "Number of test inputs to attack"
    )
    flags.DEFINE_float("learning_rate", LEARNING_RATE, "Learning rate for training")
    flags.DEFINE_string("model_path", MODEL_PATH, "Path to save or load the model file")
    flags.DEFINE_integer(
        "attack_iterations",
        ATTACK_ITERATIONS,
        "Number of iterations to run attack; 1000 is good",
    )
    flags.DEFINE_boolean("targeted", TARGETED, "Run the tutorial in targeted mode?")

    tf.app.run()
Exemplo n.º 12
0
        trainer = TrainerSingleGPU(hparams)
    trainer.model_train()
    trainer.eval(inc_epoch=False)

    return trainer.finish()


def main(argv=None):
    f = {x: flags.FLAGS[x].value for x in dir(flags.FLAGS)}
    HParams = namedtuple('HParams', f.keys())
    hparams = HParams(**f)
    run_trainer(hparams)


if __name__ == '__main__':
    flags.DEFINE_integer('train_start', 0,
                         'Index of first training set example.')
    flags.DEFINE_integer('train_end', 60000,
                         'Index of last training set example.')
    flags.DEFINE_integer('test_start', 0, 'Index of first test set example.')
    flags.DEFINE_integer('test_end', 10000, 'Index of last test set example.')
    flags.DEFINE_integer('nb_epochs', 6, 'Number of epochs to train model.')
    flags.DEFINE_integer('batch_size', 128, 'Size of training batches.')
    flags.DEFINE_boolean('adv_train', False,
                         'Whether to do adversarial training.')
    flags.DEFINE_boolean('save', True, 'Whether to save from a checkpoint.')
    flags.DEFINE_string('save_dir', 'runs/X', 'Location to store logs/model.')
    flags.DEFINE_string('model_type', 'madry',
                        'Model type: basic|madry|resnet_tf.')
    flags.DEFINE_string(
        'attack_type_train', 'MadryEtAl_y_multigpu',
        'Attack type for adversarial training:\
Exemplo n.º 13
0
        raise ValueError(argv)
    print_accuracies(
        filepath=filepath,
        test_start=FLAGS.test_start,
        test_end=FLAGS.test_end,
        which_set=FLAGS.which_set,
        nb_iter=FLAGS.nb_iter,
        base_eps_iter=FLAGS.base_eps_iter,
        batch_size=FLAGS.batch_size,
    )


if __name__ == "__main__":
    flags.DEFINE_integer(
        "train_start",
        TRAIN_START,
        "Starting point (inclusive)"
        "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "train_end",
        TRAIN_END,
        "Ending point (non-inclusive) "
        "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "test_start",
        TEST_START,
        "Starting point (inclusive) "
        "of range of test examples to use",
    )
    flags.DEFINE_integer(
    try:
        _name_of_script, filepath = argv
    except ValueError:
        raise ValueError(argv)
    print(filepath)
    make_confidence_report_bundled(filepath=filepath,
                                   test_start=FLAGS.test_start,
                                   test_end=FLAGS.test_end,
                                   which_set=FLAGS.which_set,
                                   recipe=FLAGS.recipe,
                                   report_path=FLAGS.report_path)


if __name__ == '__main__':
    flags.DEFINE_integer(
        'train_start', TRAIN_START, 'Starting point (inclusive)'
        'of range of train examples to use')
    flags.DEFINE_integer(
        'train_end', TRAIN_END, 'Ending point (non-inclusive) '
        'of range of train examples to use')
    flags.DEFINE_integer(
        'test_start', TEST_START, 'Starting point (inclusive) '
        'of range of test examples to use')
    flags.DEFINE_integer(
        'test_end', TEST_END, 'End point (non-inclusive) of '
        'range of test examples to use')
    flags.DEFINE_string('recipe', RECIPE,
                        'Name of function from attack_bundling'
                        ' to run')
    flags.DEFINE_string('which_set', WHICH_SET, '"train" or "test"')
    flags.DEFINE_string('report_path', REPORT_PATH, 'Report path')
Exemplo n.º 15
0
            sess, x, y, preds_2_adv, x_train, y_train, args=eval_params
        )
        report.train_adv_train_adv_eval = accuracy

    return report


def main(argv=None):
    from cleverhans_tutorials import check_installation

    check_installation(__file__)

    mnist_tutorial(
        nb_epochs=FLAGS.nb_epochs,
        batch_size=FLAGS.batch_size,
        learning_rate=FLAGS.learning_rate,
        train_dir=FLAGS.train_dir,
        filename=FLAGS.filename,
        load_model=FLAGS.load_model,
    )


if __name__ == "__main__":
    flags.DEFINE_integer("nb_epochs", NB_EPOCHS, "Number of epochs to train model")
    flags.DEFINE_integer("batch_size", BATCH_SIZE, "Size of training batches")
    flags.DEFINE_float("learning_rate", LEARNING_RATE, "Learning rate for training")
    flags.DEFINE_string("train_dir", TRAIN_DIR, "Directory where to save model.")
    flags.DEFINE_string("filename", FILENAME, "Checkpoint filename.")
    flags.DEFINE_boolean("load_model", LOAD_MODEL, "Load saved model or train.")
    tf.app.run()
Exemplo n.º 16
0
    mnist_blackbox(nb_classes=FLAGS.nb_classes,
                   batch_size=FLAGS.batch_size,
                   learning_rate=FLAGS.learning_rate,
                   nb_epochs=FLAGS.nb_epochs,
                   holdout=FLAGS.holdout,
                   data_aug=FLAGS.data_aug,
                   nb_epochs_s=FLAGS.nb_epochs_s,
                   lmbda=FLAGS.lmbda,
                   aug_batch_size=FLAGS.data_aug_batch_size)


if __name__ == '__main__':

    # General flags
    flags.DEFINE_integer('nb_classes', NB_CLASSES,
                         'Number of classes in problem')
    flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
    flags.DEFINE_float('learning_rate', LEARNING_RATE,
                       'Learning rate for training')

    # Flags related to oracle
    flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                         'Number of epochs to train model')

    # Flags related to substitute
    flags.DEFINE_integer('holdout', HOLDOUT, 'Test set holdout for adversary')
    flags.DEFINE_integer('data_aug', DATA_AUG,
                         'Number of substitute data augmentations')
    flags.DEFINE_integer('nb_epochs_s', NB_EPOCHS_S,
                         'Training epochs for substitute')
    flags.DEFINE_float('lmbda', LMBDA, 'Lambda from arxiv.org/abs/1602.02697')
Exemplo n.º 17
0
        nb_classes=FLAGS.nb_classes,
        batch_size=FLAGS.batch_size,
        learning_rate=FLAGS.learning_rate,
        nb_epochs=FLAGS.nb_epochs,
        holdout=FLAGS.holdout,
        data_aug=FLAGS.data_aug,
        nb_epochs_s=FLAGS.nb_epochs_s,
        lmbda=FLAGS.lmbda,
        aug_batch_size=FLAGS.data_aug_batch_size,
    )


if __name__ == "__main__":

    # General flags
    flags.DEFINE_integer("nb_classes", NB_CLASSES, "Number of classes in problem")
    flags.DEFINE_integer("batch_size", BATCH_SIZE, "Size of training batches")
    flags.DEFINE_float("learning_rate", LEARNING_RATE, "Learning rate for training")

    # Flags related to oracle
    flags.DEFINE_integer("nb_epochs", NB_EPOCHS, "Number of epochs to train model")

    # Flags related to substitute
    flags.DEFINE_integer("holdout", HOLDOUT, "Test set holdout for adversary")
    flags.DEFINE_integer(
        "data_aug", DATA_AUG, "Number of substitute data augmentations"
    )
    flags.DEFINE_integer("nb_epochs_s", NB_EPOCHS_S, "Training epochs for substitute")
    flags.DEFINE_float("lmbda", LMBDA, "Lambda from arxiv.org/abs/1602.02697")
    flags.DEFINE_integer(
        "data_aug_batch_size", AUG_BATCH_SIZE, "Batch size for augmentation"
Exemplo n.º 18
0
        "TSNE of Sign of Adv Gradients, SNNLCrossEntropy Model, factor:" +
        str(FLAGS.SNNL_factor),
        fontsize=42)
    imscatter(X_embedded, x_test[:batch_size], zoom=2, cmap="Purples")
    plt.savefig(output_dir + 'adversarial_gradients_SNNL_factor_' +
                str(SNNL_factor) + '.png')


def main(argv=None):
    SNNL_example(nb_epochs=FLAGS.nb_epochs,
                 batch_size=FLAGS.batch_size,
                 learning_rate=FLAGS.learning_rate,
                 nb_filters=FLAGS.nb_filters,
                 SNNL_factor=FLAGS.SNNL_factor,
                 output_dir=FLAGS.output_dir)


if __name__ == '__main__':
    flags.DEFINE_integer('nb_filters', NB_FILTERS, 'Model size multiplier')
    flags.DEFINE_integer('nb_epochs', NB_EPOCHS,
                         'Number of epochs to train model')
    flags.DEFINE_integer('batch_size', BATCH_SIZE, 'Size of training batches')
    flags.DEFINE_float('SNNL_factor', SNNL_FACTOR,
                       'Multiplier for Soft Nearest Neighbor Loss')
    flags.DEFINE_float('learning_rate', LEARNING_RATE,
                       'Learning rate for training')
    flags.DEFINE_string('output_dir', OUTPUT_DIR,
                        'output directory for saving figures')

    tf.app.run()
Exemplo n.º 19
0
    print(filepath)
    make_confidence_report_bundled(
        filepath=filepath,
        test_start=FLAGS.test_start,
        test_end=FLAGS.test_end,
        which_set=FLAGS.which_set,
        recipe=FLAGS.recipe,
        report_path=FLAGS.report_path,
        batch_size=FLAGS.batch_size,
    )


if __name__ == "__main__":
    flags.DEFINE_integer(
        "train_start",
        TRAIN_START,
        "Starting point (inclusive)"
        "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "train_end",
        TRAIN_END,
        "Ending point (non-inclusive) "
        "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "test_start",
        TEST_START,
        "Starting point (inclusive) "
        "of range of test examples to use",
    )
    flags.DEFINE_integer(
Exemplo n.º 20
0
    from cleverhans_tutorials import check_installation

    check_installation(__file__)

    cifar10_tutorial(
        nb_epochs=FLAGS.nb_epochs,
        batch_size=FLAGS.batch_size,
        learning_rate=FLAGS.learning_rate,
        clean_train=FLAGS.clean_train,
        backprop_through_attack=FLAGS.backprop_through_attack,
        nb_filters=FLAGS.nb_filters,
    )


if __name__ == "__main__":
    flags.DEFINE_integer("nb_filters", NB_FILTERS, "Model size multiplier")
    flags.DEFINE_integer("nb_epochs", NB_EPOCHS,
                         "Number of epochs to train model")
    flags.DEFINE_integer("batch_size", BATCH_SIZE, "Size of training batches")
    flags.DEFINE_float("learning_rate", LEARNING_RATE,
                       "Learning rate for training")
    flags.DEFINE_bool("clean_train", CLEAN_TRAIN, "Train on clean examples")
    flags.DEFINE_bool(
        "backprop_through_attack",
        BACKPROP_THROUGH_ATTACK,
        ("If True, backprop through adversarial example "
         "construction process during adversarial training"),
    )

    tf.app.run()
Exemplo n.º 21
0
        test_start=FLAGS.test_start,
        test_end=FLAGS.test_end,
        which_set=FLAGS.which_set,
        report_path=FLAGS.report_path,
        mc_batch_size=FLAGS.mc_batch_size,
        nb_iter=FLAGS.nb_iter,
        base_eps_iter=FLAGS.base_eps_iter,
        batch_size=FLAGS.batch_size,
        save_advx=FLAGS.save_advx,
    )


if __name__ == "__main__":
    flags.DEFINE_integer(
        "train_start",
        TRAIN_START,
        "Starting point (inclusive)" "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "train_end",
        TRAIN_END,
        "Ending point (non-inclusive) " "of range of train examples to use",
    )
    flags.DEFINE_integer(
        "test_start",
        TEST_START,
        "Starting point (inclusive) " "of range of test examples to use",
    )
    flags.DEFINE_integer(
        "test_end",
        TEST_END,