I'm currently experimenting with scikit-learn's neural net capabilites. Is there are way to set the number of output nodes in its MLPClassifier? I know you can set the number of hidden layers by passing it as parameters like:
clf = MLPClassifier(hidden_layer_sizes=(100,)
Thanks
max_iter: It denotes the number of epochs. activation: The activation function for the hidden layers. solver: This parameter specifies the algorithm for weight optimization across the nodes.
3.3 MLPClassifier hidden_layer_sizes : With this parameter we can specify the number of layers and the number of nodes we want to have in the Neural Network Classifier. Each element in the tuple represents the number of nodes at the ith position, where i is the index of the tuple.
max_iterint, default=200. Maximum number of iterations. The solver iterates until convergence (determined by 'tol') or this number of iterations. For stochastic solvers ('sgd', 'adam'), note that this determines the number of epochs (how many times each data point will be used), not the number of gradient steps.
The number of output nodes is dependent on the size of your labels.
An example of the User Guide for Neural Networks:
>>> from sklearn.neural_network import MLPClassifier
>>> X = [[0., 0.], [1., 1.]]
>>> y = [[0, 1], [1, 1]]
>>> clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
... hidden_layer_sizes=(15,), random_state=1)
>>> clf.fit(X, y)
>>> clf.predict([[1., 2.]])
array([[1, 1]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With