Make a confidence report and save it to disk.

def main(argv=None):
  """
  Make a confidence report and save it to disk.
  """
  assert len(argv) >= 3
  _name_of_script = argv[0]
  model_filepath = argv[1]
  adv_x_filepaths = argv[2:]

  sess = tf.Session()
  with sess.as_default():
    model = serial.load(model_filepath)

  factory = model.dataset_factory
  factory.kwargs['train_start'] = FLAGS.train_start
  factory.kwargs['train_end'] = FLAGS.train_end
  factory.kwargs['test_start'] = FLAGS.test_start
  factory.kwargs['test_end'] = FLAGS.test_end
  dataset = factory()

  adv_x_list = [np.load(filepath) for filepath in adv_x_filepaths]
  x, y = dataset.get_set(FLAGS.which_set)
  for adv_x in adv_x_list:
    assert adv_x.shape == x.shape, (adv_x.shape, x.shape)
    # Make sure these were made for the right dataset with right scaling
    # arguments, etc.
    assert adv_x.min() >= 0. - dataset.kwargs['center'] * dataset.max_val
    assert adv_x.max() <= dataset.max_val
    data_range = dataset.max_val * (1. + dataset.kwargs['center'])

    if adv_x.max() - adv_x.min() <= .8 * data_range:
      warnings.warn("Something is weird. Your adversarial examples use "
                    "less than 80% of the data range."
                    "This might mean you generated them for a model with "
                    "inputs in [0, 1] and are now using them for a model "
                    "with inputs in [0, 255] or something like that. "
                    "Or it could be OK if you're evaluating on a very small "
                    "batch.")

  report_path = FLAGS.report_path
  if report_path is None:
    suffix = "_bundled_examples_report.joblib"
    assert model_filepath.endswith('.joblib')
    report_path = model_filepath[:-len('.joblib')] + suffix

  goal = MaxConfidence()
  bundle_examples_with_goal(sess, model, adv_x_list, y, goal,
                            report_path, batch_size=FLAGS.batch_size)