'Sklearn MLP Classifier Hyperparameter Optimization (RandomizedSearchCV)

I have the following parameters set up :

parameter_space = {
    'hidden_layer_sizes': [(sp_randint(100,600),sp_randint(100,600),), (sp_randint(100,600),)],
    'activation': ['tanh', 'relu', 'logistic'],
    'solver': ['sgd', 'adam', 'lbfgs'],
    'alpha': stats.uniform(0.0001, 0.9),
    'learning_rate': ['constant','adaptive']}

All the parameters except the hidden_layer_sizes is working as expected. However, fitting this RandomizedSearchCV model and displaying it's verbose text shows that it treats hidden_layer_sizes as :

hidden_layer_sizes=(<scipy.stats._distn_infrastructure.rv_frozen object and goes on to throw : TypeError: '<=' not supported between instances of 'rv_frozen' and 'int'

This result is obtained instead of the expected 1 or 2 layer MLP with hidden layer neurons between 100 and 600. Any ideas / other related tips?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source