Search code examples
pythonscikit-learnneural-networkperceptron

create single perceptron with scikits MLPregressor


I use sklearn.neural_networks MLPRegressor

Do I understand it right, that by choosing hidden_layer_sizes=(1, ) I create a single perceptron because the first "hidden layer" is nothing else than the neurons that learn from the input layer?


Solution

  • When you set hidden_layer_size=(1,) you create a network with 1 hidden layer with size 1 neuron. It means instead of a Single-Layer Perceptron which has no hidden layer, you create a Multi-Layer Perceptron with 1 hidden layer with size 1 neuron.

    you can read it from here: http://scikit-learn.org/stable/modules/generated/sklearn.neural_network.MLPRegressor.html

    hidden_layer_sizes : tuple, length = n_layers - 2, default (100,)

    n-layers - 2 means the value in hidden_layer_size is not included the first layer (input layer) and the last layer (output layer)

    To create a Single Layer Perceptron, set it to empty: hidden_layer_size=()