How to use the cleverhans.compat.flags.DEFINE_string function in cleverhans

To help you get started, we’ve selected a few cleverhans examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / cleverhans / scripts / make_confidence_report_spsa.py View on Github external
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, 'Number of iterations of SPSA')
  flags.DEFINE_string('which_set', WHICH_SET, '"train" or "test"')
  flags.DEFINE_string('report_path', REPORT_PATH, 'Path to save to')
  flags.DEFINE_integer('batch_size', BATCH_SIZE,
                       'Batch size for most jobs')
  tf.app.run()
github tensorflow / cleverhans / scripts / make_confidence_report.py View on Github external
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')
  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]')
  flags.DEFINE_integer('save_advx', SAVE_ADVX,
                       'If True, saves the adversarial examples to the '
                       'filesystem.')
  tf.app.run()
github tensorflow / cleverhans / cleverhans_tutorials / mnist_tutorial_keras_tf.py View on Github external
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()
github tensorflow / cleverhans / cleverhans / model_zoo / soft_nearest_neighbor_loss / SNNL_regularized_train.py View on Github external
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()
github tensorflow / cleverhans / examples / multigpu_advtrain / run_multigpu.py View on Github external
flags.DEFINE_string('dataset', 'mnist', 'Dataset mnist|cifar10.')
  flags.DEFINE_boolean('only_adv_train', False,
                       'Do not train with clean examples when adv training.')
  flags.DEFINE_integer('save_steps', 50, 'Save model per X steps.')
  flags.DEFINE_integer('attack_nb_iter_train', None,
                       'Number of iterations of training attack.')
  flags.DEFINE_integer('eval_iters', 1, 'Evaluate every X steps.')
  flags.DEFINE_integer('lrn_step', 30000, 'Step to decrease learning rate'
                       'for ResNet.')
  flags.DEFINE_float('adam_lrn', 0.001, 'Learning rate for Adam Optimizer.')
  flags.DEFINE_float('mom_lrn', 0.1,
                     'Learning rate for Momentum Optimizer.')
  flags.DEFINE_integer('ngpu', 1, 'Number of gpus.')
  flags.DEFINE_integer('sync_step', 1, 'Sync params frequency.')
  flags.DEFINE_boolean('fast_tests', False, 'Fast tests against attacks.')
  flags.DEFINE_string('data_path', './datasets/', 'Path to datasets.'
                      'Each dataset should be in a subdirectory.')

  app.run()
github tensorflow / cleverhans / cleverhans_tutorials / mnist_tutorial_keras_tf.py View on Github external
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()
github tensorflow / cleverhans / scripts / make_confidence_report_spsa.py View on Github external
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, 'Number of iterations of SPSA')
  flags.DEFINE_string('which_set', WHICH_SET, '"train" or "test"')
  flags.DEFINE_string('report_path', REPORT_PATH, 'Path to save to')
  flags.DEFINE_integer('batch_size', BATCH_SIZE,
                       'Batch size for most jobs')
  tf.app.run()
github tensorflow / cleverhans / scripts / make_confidence_report_bundle_examples.py View on Github external
goal = MaxConfidence()
  bundle_examples_with_goal(sess, model, adv_x_list, y, goal,
                            report_path, batch_size=FLAGS.batch_size)


if __name__ == '__main__':
  flags.DEFINE_string('report_path', None, 'Report path')
  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('which_set', WHICH_SET, '"train" or "test"')
  flags.DEFINE_integer('batch_size', BATCH_SIZE, 'batch size')
  tf.app.run()