Talos --> hidden_layers(model, params, 1) SyntaxError: invalid syntax

144 Views Asked by At

I've been trying to implement a simple MLP for hyperparameter tuning with Talos 1.0.0, but was having a syntax error. Bellow is the code snippet:

    def get_model(x_train, y_train, x_val, y_val, params):
        dim = x_train.shape[1]

        model = Sequential()
        model.add(BatchNormalization(input_dim=dim))
        model.add(Dense(params['first_neuron'], activation=params['activation'], kernel_initializer='he_uniform')

        hidden_layers(model, params, 1)

        model.add(Dense(units = 1, activation = 'sigmoid'))

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

        history = model.fit(x_train, y_train, batch_size=params['batch_size'], epochs=params['epochs'], 
                    verbose=0, class_weight=class_weights, validation_data=[x_val, y_val], 
                    callbacks=[early_stopper(epochs=params['epochs'], mode='moderate', monitor='val_loss')])

        return history, model

Note: I've tried both, importing hidden_layers() from talos.model (from talos.model import hidden_layers) and from talos.utils (from talos.utils import hidden_layers). Could anyone help identify and sort out the issue?

0

There are 0 best solutions below