You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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_))
The text was updated successfully, but these errors were encountered:
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
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_))
The text was updated successfully, but these errors were encountered: