autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 268 forks source link

Add hidden_Layers in documentation examples #307

Closed zutron closed 5 years ago

zutron commented 5 years ago

Just a quick note for a possible error in your documentation/examples.

Of the four examples you list (Simple, Concise, Comprehensive, Field Report), only the Concise example makes use of the _hiddenlayers search parameter. However, while it is defined in the parameter dictionary ('hidden_layers':[0, 1, 2]) , the hidden_layers(model, params, 1) call is never made during model creation. I expect that the Concise example is defaulting to a single hidden layer in this example, and the code should be updated to:

from talos.model import hidden_layers    # Needed for fix below

def breast_cancer_model(x_train, y_train, x_val, y_val, params):

    model = Sequential()
    model.add(Dense(params['first_neuron'], input_dim=x_train.shape[1],
                activation=params['activation'],
                kernel_initializer=params['kernel_initializer']))

    model.add(Dropout(params['dropout']))

    hidden_layers(model, params, 1) # Fix to add call to hidden_layers()

    model.add(Dense(1, activation=params['last_activation'],
                kernel_initializer=params['kernel_initializer']))

    model.compile(loss=params['losses'],
              optimizer=params['optimizer'](),
              metrics=['acc', fmeasure_acc])

    history = model.fit(x_train, y_train, 
                    validation_data=[x_val, y_val],
                    batch_size=params['batch_size'],
                    callbacks=[live()],
                    epochs=params['epochs'],
                    verbose=0)

    return history, model

Please correct me if I am wrong :)

mikkokotila commented 5 years ago

You are right :) Thanks.

mikkokotila commented 5 years ago

This is now handled in the new docs for v.0.6.2. Already visible in /docs in daily-dev. Closing here.