title: KerasTuner Custom Objective Function
body: <p>I am trying to use Keras Tuner for my hyper-parameter fine tuning. I would like to maximize <code>auc</code>. Can anyone help me with using <code>kerastuner.Objective</code> for a custom metric ?</p>
  
  <pre><code>EXECUTIONS_PER_TRIAL = 5
  
  b_tuner = BayesianOptimization(
      tune_nn_model,
      objective='val_binary_accuracy',
      max_trials=MAX_TRIALS,
      executions_per_trial=EXECUTIONS_PER_TRIAL,
      directory='test_dir101897',
      project_name='b_tune_nn',
      seed=12347
  )
  </code></pre>
  
  <p>I tried defining a custom function like : </p>
  
  <pre><code>from sklearn import metrics
  from keras import backend as K
  
  def auc(y_true, y_pred):
      auc = tf.metrics.auc(y_true, y_pred)[1]
      K.get_session().run(tf.local_variables_initializer())
      return auc
  </code></pre>
  
  <p>and plug it in</p>
  
  <pre><code>objective='val_auc'
  </code></pre>
  
  <p>But this does not work</p>