maxpumperla / hyperas

Keras + Hyperopt: A very simple wrapper for convenient hyperparameter optimization
http://maxpumperla.com/hyperas/
MIT License
2.17k stars 316 forks source link

Space names are confusing/unintuitive for Conv2D layers #216

Open deKeijzer opened 5 years ago

deKeijzer commented 5 years ago

Now this is not a huge problem, but bringing it to light and letting someone change this will improve the user friendliness of Hyperas.

Short example of the problem:

def create_model(X_train, y_train, X_test, y_test):
     input_shape = (X_train.shape[1], X_train.shape[2], X_train.shape[3])

     model = Sequential()

     ks1_first = {{choice([2, 3, 4, 5, 8, 10])}} # Where ks stands for kernel_size
     ks1_second = {{choice([2, 3, 4, 5, 8, 10])}}

     ks2_first = {{choice([2, 3, 4, 5, 8, 10])}}
     ks2_second = {{choice([2, 3, 4, 5, 8, 10])}}

     model.add(Conv2D(filters=( {{choice([1, 2, 3, 4, 5, 8, 12])}} ), 
                 kernel_size=(ks1_first, ks1_second),
                 input_shape=input_shape, 
                 padding='same',
                 kernel_initializer='TruncatedNormal'))
     model.add(BatchNormalization())
     model.add(LeakyReLU())
     model.add(Dropout( {{uniform(0, 1)}} ))

     for _ in range( {{choice([0, 1, 2, 3])}} ):
         model.add(Conv2D(filters=( {{choice([4, 8, 12])}} ), 
                 kernel_size= (ks2_first, ks2_second), 
                     padding='same',
                 kernel_initializer='TruncatedNormal'))
         model.add(BatchNormalization())
         model.add(LeakyReLU())
         model.add(Dropout( {{uniform(0, 1)}} ))  

     model.add(Flatten())

    #More layers... `

In here the spaces ks1_first, ks1_second, ks2_first ... should intuitively be expected to have space names equal to their variable names. Same for filters within the Conv2D() layer. Unfortunately they are labelled as follows:

output

Notice the space names from the ks1_first, ks1_second, ks2_first, ks2_second variables but also that ks1_first_4 becomes the first filter and range_1 the second filter.

I'm running hyperas 0.4.

The complete code can be found here

maxpumperla commented 5 years ago

@deKeijzer you're right that this is annoying. it's difficult to map properly with hyperas' approach to things. Meaning: hyperas has to cook up names for you depending on how you choose to name things.

Having said that, in your example how would you propose to name things? after everything coming before an = sign of an opening bracket (? Currently, if hyperas doesn't find a good name, it will take the previous one and increase a suffix counter.

deKeijzer commented 5 years ago

@maxpumperla It would be great having it pick the variable name before the = and =( signs, exactly like you say.