def prep_bbox(sess, x, y, x_train, y_train, x_test, y_test,
              nb_epochs, batch_size, learning_rate,
              rng, nb_classes=10, img_rows=28, img_cols=28, nchannels=1):
  """
  Define and train a model that simulates the "remote"
  black-box oracle described in the original paper.
  :param sess: the TF session
  :param x: the input placeholder for MNIST
  :param y: the ouput placeholder for MNIST
  :param x_train: the training data for the oracle
  :param y_train: the training labels for the oracle
  :param x_test: the testing data for the oracle
  :param y_test: the testing labels for the oracle
  :param nb_epochs: number of epochs to train model
  :param batch_size: size of training batches
  :param learning_rate: learning rate for training
  :param rng: numpy.random.RandomState
  :return:
  """

  # Define TF model graph (for the black-box model)
  nb_filters = 64
  model = ModelBasicCNN('model1', nb_classes, nb_filters)
  loss = CrossEntropy(model, smoothing=0.1)
  predictions = model.get_logits(x)
  print("Defined TensorFlow model graph.")

  # Train an MNIST model
  train_params = {
      'nb_epochs': nb_epochs,
      'batch_size': batch_size,
      'learning_rate': learning_rate
  }
  train(sess, loss, x_train, y_train, args=train_params, rng=rng)

  # Print out the accuracy on legitimate data
  eval_params = {'batch_size': batch_size}
  accuracy = model_eval(sess, x, y, predictions, x_test, y_test,
                        args=eval_params)
  print('Test accuracy of black-box on legitimate test '
        'examples: ' + str(accuracy))

  return model, predictions, accuracy
def prep_bbox ( sess , x , y , x_train , y_train , x_test , y_test , nb_epochs , batch_size , learning_rate , rng , nb_classes = 10 , img_rows = 28 , img_cols = 28 , nchannels = 1 ) : nb_filters = 64 model = ModelBasicCNN ( 'model1' , nb_classes , nb_filters ) loss = CrossEntropy ( model , smoothing = 0.1 ) predictions = model . get_logits ( x ) print ( "Defined TensorFlow model graph." ) train_params = { 'nb_epochs' : nb_epochs , 'batch_size' : batch_size , 'learning_rate' : learning_rate } train ( sess , loss , x_train , y_train , args = train_params , rng = rng ) eval_params = { 'batch_size' : batch_size } accuracy = model_eval ( sess , x , y , predictions , x_test , y_test , args = eval_params ) print ( 'Test accuracy of black-box on legitimate test ' 'examples: ' + str ( accuracy ) ) return model , predictions , accuracy
Define and train a model that simulates the "remote"
  black-box oracle described in the original paper.
  :param sess: the TF session
  :param x: the input placeholder for MNIST
  :param y: the ouput placeholder for MNIST
  :param x_train: the training data for the oracle
  :param y_train: the training labels for the oracle
  :param x_test: the testing data for the oracle
  :param y_test: the testing labels for the oracle
  :param nb_epochs: number of epochs to train model
  :param batch_size: size of training batches
  :param learning_rate: learning rate for training
  :param rng: numpy.random.RandomState
  :return: