autonomio / talos

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

NameError: name 'commands' is not defined #344

Closed Mattia9494 closed 5 years ago

Mattia9494 commented 5 years ago

I just copy pasted the example from the code like this:

from numpy import loadtxt

dataset = loadtxt("https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv", delimiter=",")
x = dataset[:,0:8]
y = dataset[:,8]

from keras.models import Sequential
from keras.layers import Dense

def diabetes():

    model = Sequential()
    model.add(Dense(12, input_dim=8, activation='relu'))
    model.add(Dense(8, activation='relu'))
    model.add(Dense(1, activation='sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
    model.fit(X, Y, epochs=100, batch_size=10, verbose=0)

    return model

from keras.activations import relu, elu

p = {
    'first_neuron': [12, 24, 48],
    'activation': [relu, elu],
    'batch_size': [10, 20, 30]
}

# add input parameters to the function
def diabetes(x_train, y_train, x_val, y_val, params):

    # replace the hyperparameter inputs with references to params dictionary 
    model = Sequential()
    model.add(Dense(params['first_neuron'], input_dim=8, activation=params['activation']))
    #model.add(Dense(8, activation=params['activation']))
    model.add(Dense(1, activation='sigmoid'))
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

    # make sure history object is returned by model.fit()
    out = model.fit(x, y,
                    epochs=100,
                    batch_size=params['batch_size'],
                    #validation_split=.3,
                    verbose=0)

    # modify the output model
    return out, model

import talos as ta

t = ta.Scan(x, y, p, diabetes)

and I keep receiving the follosing error:

Traceback (most recent call last):

File "", line 51, in import talos as ta

File "/Users/mattiavicari/anaconda3/envs/Optimize_DL/lib/python3.7/site-packages/talos/init.py", line 30, in del commands, scan, model, metrics, key

NameError: name 'commands' is not defined

Is there any fix available? Note that I have installed talos with the updated github version. Thanks so much in advance!

mikkokotila commented 5 years ago

I think you are in a notebook, and you did not restart the notebook after an import error.

mikkokotila commented 5 years ago

Closing here as resolved. Feel free to open new issue if anything.