コード例 #1
0
def main():
    args = parser.parse_args()
    pp = pprint.PrettyPrinter()
    pp.pprint(vars(args))

    # Data
    filename_queue = get_filename_queue(
        split_file=os.path.join(args.data_dir, 'splits', args.dataset,
                                args.split + '.lst'),
        data_dir=os.path.join(args.data_dir, args.dataset))
    # test data
    test_filename_queue = get_filename_queue(
        split_file=os.path.join(args.data_dir, 'splits', args.dataset,
                                'test.lst'),
        data_dir=os.path.join(args.data_dir, args.dataset))

    image, label = get_input_cifar10(filename_queue)
    output_size = 32
    c_dim = 3

    test_image, test_label = get_input_cifar10(test_filename_queue)

    image_batch = create_batch([image, label],
                               batch_size=args.batch_size,
                               num_preprocess_threads=16,
                               min_queue_examples=10000)

    test_image_batch = tf.train.shuffle_batch([test_image, test_label],
                                              batch_size=args.batch_size,
                                              num_threads=16,
                                              capacity=10000 +
                                              3 * args.batch_size,
                                              min_after_dequeue=10000)

    config = vars(args)

    discriminator = models.get_discriminator(args.d_architecture,
                                             scope='discriminator',
                                             output_size=output_size,
                                             c_dim=args.c_dim,
                                             f_dim=args.df_dim,
                                             is_training=True)

    gen_adv_examples(discriminator, args.model_file, image_batch,
                     test_image_batch, config)
コード例 #2
0
def main():
    args = parser.parse_args()
    pp = pprint.PrettyPrinter()
    pp.pprint(vars(args))

    # Test data
    test_filename_queue = get_filename_queue(
        split_file=os.path.join(args.data_dir, 'splits', args.dataset,
                                'test.lst'),
        data_dir=os.path.join(args.data_dir, args.dataset))

    test_image, test_label = get_input_cifar10(test_filename_queue)

    test_image_batch = tf.train.shuffle_batch([test_image, test_label],
                                              batch_size=args.batch_size,
                                              num_threads=16,
                                              capacity=10000 +
                                              3 * args.batch_size,
                                              min_after_dequeue=10000)

    config = vars(args)

    discriminator1 = models.get_discriminator(args.d_architecture1,
                                              scope='discriminator1',
                                              output_size=args.output_size,
                                              c_dim=args.c_dim,
                                              f_dim=args.df_dim,
                                              is_training=True)
    discriminator2 = models.get_discriminator(args.d_architecture2,
                                              scope='discriminator2',
                                              output_size=args.output_size,
                                              c_dim=args.c_dim,
                                              f_dim=args.df_dim,
                                              is_training=True)

    black_box_attacks(discriminator1, discriminator2, args.model_file1,
                      args.model_file2, test_image_batch, config)