Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How pass a number of neurons in the model for KerasClassifier :Invalid parameter neurons for estimator KerasClassifier. #318

Open
AntonioConstantino opened this issue Mar 27, 2024 · 0 comments

Comments

@AntonioConstantino
Copy link

AntonioConstantino commented Mar 27, 2024

Error: Check the list of available parameters with estimator.get_params().keys()

In the function define a neurons parameter, but when you pass through KerasClassifier the parameters do not allow that optimization or the passing of that parameter, for your best guess please

model :

def build_model(optimizer='adam', neurons=60):
model=Sequential()
model.add(Embedding(NUM_PALABRAS, neurons, input_length=longitud_maxima))
model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dense(12, activation='relu'))
model.add(Dropout(0.3))
model.add(Dense(len(generos), activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy'])
return model

neurons = [30, 60, 90]
batch_size = [10]
optimizer = ['adam', 'rmsprop']

param_grids = dict(neurons=neurons, batch_size=batch_size, optimizer=optimizer)
model = KerasClassifier(build_fn=build_model, verbose=2)

grid = GridSearchCV(estimator=model, param_grid=param_grids, n_jobs=-1)
result = grid.fit(X_train, y_train,)

print("Best: {} using {}".format(result.best_score_, result.best_params_))

@AntonioConstantino AntonioConstantino changed the title Invalid parameter neurons for estimator KerasClassifier. How pass a number of neurons in the model for KerasClassifier :Invalid parameter neurons for estimator KerasClassifier. Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant