code: def model(x_train, y_train, x_test, y_test):
      """
      Model providing function:
  
      Create Keras model with double curly brackets dropped-in as needed.
      Return value has to be a valid python dictionary with two customary keys:
          - loss: Specify a numeric evaluation metric to be minimized
          - status: Just use STATUS_OK and see hyperopt documentation if not feasible
      The last one is optional, though recommended, namely:
          - model: specify the model just created so that we can later use it again.
      """
      model = Sequential()
      model.add(Dense(512, input_shape=(784,)))
      model.add(Activation("relu"))
      model.add(Dropout({{uniform(0, 1)}}))
      model.add(Dense({{choice([256, 512, 1024])}}))
      model.add(Activation({{choice(["relu", "sigmoid"])}}))
      model.add(Dropout({{uniform(0, 1)}}))
  
      # If we choose 'four', add an additional fourth layer
      if {{choice(["three", "four"])}} == "four":
          model.add(Dense(100))
  
          # We can also choose between complete sets of layers
  
          model.add({{choice([Dropout(0.5), Activation("linear")])}})
          model.add(Activation("relu"))
  
      model.add(Dense(10))
      model.add(Activation("softmax"))
  
      model.compile(
          loss="categorical_crossentropy",
          metrics=["accuracy"],
          optimizer={{choice(["rmsprop", "adam", "sgd"])}},
      )
  
      model.fit(
          x_train,
          y_train,
          batch_size={{choice([64, 128])}},
          epochs=1,
          verbose=2,
          validation_data=(x_test, y_test),
      )
      score, acc = model.evaluate(x_test, y_test, verbose=0)
      print("Test accuracy:", acc)
      return {"loss": -acc, "status": STATUS_OK, "model": model}
  
file_path: hyperas/examples/mnist_readme.py
imports: from __future__ import print_function
  from hyperopt import Trials, STATUS_OK, tpe
  from keras.datasets import mnist
  from keras.layers.core import Dense, Dropout, Activation
  from keras.models import Sequential
  from keras.utils import np_utils
  from hyperas import optim
  from hyperas.distributions import choice, uniform
label_desc: Use image node_id 2 for calling a global function with example usage: model(x_train, y_train, x_test, y_test) and returns: dict