title: Error trying to pass list to hyperas as a parameter
body: <p>I'm working on hyper-paramter optimization using keras and the <a href="https://github.com/maxpumperla/hyperas" rel="nofollow noreferrer">hyperas library</a>.</p>
  
  <p>I'm trying to pass a list instead of a hard coded list but it throws an error. In hyperas you wrap your template value in "{{ some value }}" which you can card code to be a list. Example:</p>
  
  <pre><code>model.add(Dense({{choice([258,512,1024])}}))
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>File "hy.py", line 89, in
  trials=Trials())
  File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 67, in minimize
  verbose=verbose)
  File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 118, in base_minimizer
  space=get_space(),
  File "/home/peachy/Documents/tensorflow/temp_model.py", line 119, in get_space
  NameError: name 'dropout' is not defined
  </code></pre>
  
  <p>Using a basic example, this is the model class. I'm loading in from a yml file which loads in lists, but that doesn't work so I'm just trying to create a list in the model class and pass that in just the same. It won't work.</p>
  
  <pre><code>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, conditional
  import common_config as cfg
  
  def data():
      """
      Data providing function:
      This function is separated from model() so that hyperopt
      won't reload data for each evaluation run.
      """
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
      x_train = x_train.reshape(60000, 784)
      x_test = x_test.reshape(10000, 784)
      x_train = x_train.astype('float32')
      x_test = x_test.astype('float32')
      x_train /= 255
      x_test /= 255
      nb_classes = 10
      y_train = np_utils.to_categorical(y_train, nb_classes)
      y_test = np_utils.to_categorical(y_test, nb_classes)
      return x_train, y_train, x_test, y_test
  
  
  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.
      """
      ModelConfig = cfg.ModelConfig
      dropout = [0,1]
      print (dropout)
      print (type(dropout))
  
  
  
  
      model = Sequential()
      model.add(Dense(512, input_shape=(784,)))
      model.add(Activation(ModelConfig.activation))
      model.add(Dropout({{uniform(dropout)}}))
      model.add(Dense({{choice([258,512,1024])}}))
      model.add(Activation({{choice(['relu', 'sigmoid'])}}))
      model.add(Dropout({{uniform(0,1)}}))
  
      # If we choose 'four', add an additional fourth layer
      if conditional({{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}
  
  
  if __name__ == '__main__':
      best_run, best_model = optim.minimize(model=model,
                                            data=data,
                                            algo=tpe.suggest,
                                            max_evals=10,
                                            trials=Trials())
      X_train, Y_train, X_test, Y_test = data()
      print("Evalutation of best performing model:")
      print(best_model.evaluate(X_test, Y_test))
      print("Best performing model chosen hyper-parameters:")
      print(best_run)
  </code></pre>
  
  <p>How is the value sent from the template to the optim.py file ?
  I've checked and the regular expression should be able to handle the list.</p>
  
  <p>I don't expect anyone to know but how would you go about debugging this as it's a library issue most likely</p>
  
  <p>EDIT </p>
  
  <p>Solution 1 &amp; 2 result in just an type error being thrown which in the source code is a very strange check to see if it's a certain string type</p>
  
  <p>Hyperopt code pyll_util.py</p>
  
  <pre><code>def validate_label(f):
      @wraps(f)
      def wrapper(label, *args, **kwargs):
          is_real_string = isinstance(label, basestring)
          is_literal_string = (isinstance(label, Literal) and
                               isinstance(label.obj, basestring))
          if not is_real_string and not is_literal_string:
              raise TypeError('require string label')
          return f(label, *args, **kwargs)
      return wrapper
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>Traceback (most recent call last):
    File "hy.py", line 107, in &lt;module&gt;
      trials=Trials())
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 67, in minimize
      verbose=verbose)
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 136, in base_minimizer
      return_argmin=True),
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/fmin.py", line 307, in fmin
      return_argmin=return_argmin,
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/base.py", line 635, in fmin
      return_argmin=return_argmin)
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/fmin.py", line 320, in fmin
      rval.exhaust()
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/fmin.py", line 199, in exhaust
      self.run(self.max_evals - n_done, block_until_done=self.async)
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/fmin.py", line 173, in run
      self.serial_evaluate()
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/fmin.py", line 92, in serial_evaluate
      result = self.domain.evaluate(spec, ctrl)
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/base.py", line 840, in evaluate
      rval = self.fn(pyll_rval)
    File "/home/peachy/Documents/tensorflow/temp_model.py", line 101, in keras_fmin_fnct
    File "&lt;string&gt;", line 1, in &lt;module&gt;
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperopt/pyll_utils.py", line 21, in wrapper
      raise TypeError('require string label')
  TypeError: require string label
  </code></pre>
  
  <p>Solution 3 by merging a list results in the error below which says that %s has been based through along with dropout_1 into the temp_model file which is generated. </p>
  
  <pre><code>Unexpected error: &lt;class 'SyntaxError'&gt;
  Traceback (most recent call last):
    File "hy.py", line 107, in &lt;module&gt;
      trials=Trials())
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 67, in minimize
      verbose=verbose)
    File "/home/peachy/Documents/tensorflow/tf/lib/python3.6/site-packages/hyperas-0.4-py3.6.egg/hyperas/optim.py", line 104, in base_minimizer
      from temp_model import keras_fmin_fnct, get_space
    File "/home/peachy/Documents/tensorflow/temp_model.py", line 133
      'Dropout_1': hp.uniform('Dropout_1', %s),
                                           ^
  </code></pre>