code: def model_fn(features, labels, mode):
      # Build the neural network
      # Because Dropout have different behavior at training and prediction time, we
      # need to create 2 distinct computation graphs that still share the same weights.
      logits_train = conv_net(
          features, num_classes, reuse=False, is_training=True
      )
      logits_test = conv_net(
          features, num_classes, reuse=True, is_training=False
      )
  
      # Predictions
      pred_classes = tf.argmax(logits_test, axis=1)
      pred_probas = tf.nn.softmax(logits_test)
  
      # If prediction mode, early return
      if mode == tf.estimator.ModeKeys.PREDICT:
          return tf.estimator.EstimatorSpec(
              mode, predictions=pred_classes
          )
  
          # Define loss and optimizer
      loss_op = tf.reduce_mean(
          tf.nn.sparse_softmax_cross_entropy_with_logits(
              logits=logits_train,
              labels=tf.cast(labels, dtype=tf.int32),
          )
      )
      optimizer = tf.train.AdamOptimizer(
          learning_rate=FLAGS.learning_rate
      )
      train_op = optimizer.minimize(
          loss_op, global_step=tf.train.get_global_step()
      )
  
      # Evaluate the accuracy of the model
      acc_op = tf.metrics.accuracy(
          labels=labels, predictions=pred_classes
      )
  
      # TF Estimators requires to return a EstimatorSpec, that specify
      # the different ops for training, evaluating, ...
      estim_specs = tf.estimator.EstimatorSpec(
          mode=mode,
          predictions=pred_classes,
          loss=loss_op,
          train_op=train_op,
          eval_metric_ops={"accuracy": acc_op},
      )
  
      return estim_specs
  
file_path: auptimizer/Examples/hpo_mnist/mnist_hpo_demo.py
imports: from __future__ import division, print_function, absolute_import
  import argparse
  import os
  import sys
  from datetime import datetime
  from math import log
  import tensorflow
  from tensorflow.examples.tutorials.mnist import input_data
  from aup import BasicConfig, print_result
label_desc: Use image node_id 2 for calling a global function with example usage: model_fn(features, labels, mode) and returns: estim_specs, tf