forked from jorgecasas/php-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Backpropagation | ||
|
||
Backpropagation, an abbreviation for "backward propagation of errors", is a common method of training artificial neural networks used in conjunction with an optimization method such as gradient descent. | ||
|
||
## Constructor Parameters | ||
|
||
* $network (Network) - network to train (for example MultilayerPerceptron instance) | ||
* $theta (int) - network theta parameter | ||
|
||
``` | ||
use Phpml\NeuralNetwork\Network\MultilayerPerceptron; | ||
use Phpml\NeuralNetwork\Training\Backpropagation; | ||
$network = new MultilayerPerceptron([2, 2, 1]); | ||
$training = new Backpropagation($network); | ||
``` | ||
|
||
## Training | ||
|
||
Example of XOR training: | ||
|
||
``` | ||
$training->train( | ||
$samples = [[1, 0], [0, 1], [1, 1], [0, 0]], | ||
$targets = [[1], [1], [0], [0]], | ||
$desiredError = 0.2, | ||
$maxIteraions = 30000 | ||
); | ||
``` |
29 changes: 29 additions & 0 deletions
29
docs/machine-learning/neural-network/multilayer-perceptron.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# MultilayerPerceptron | ||
|
||
A multilayer perceptron (MLP) is a feedforward artificial neural network model that maps sets of input data onto a set of appropriate outputs. | ||
|
||
## Constructor Parameters | ||
|
||
* $layers (array) - array with layers configuration, each value represent number of neurons in each layers | ||
* $activationFunction (ActivationFunction) - neuron activation function | ||
|
||
``` | ||
use Phpml\NeuralNetwork\Network\MultilayerPerceptron; | ||
$mlp = new MultilayerPerceptron([2, 2, 1]); | ||
// 2 nodes in input layer, 2 nodes in first hidden layer and 1 node in output layer | ||
``` | ||
|
||
## Methods | ||
|
||
* setInput(array $input) | ||
* getOutput() | ||
* getLayers() | ||
* addLayer(Layer $layer) | ||
|
||
## Activation Functions | ||
|
||
* BinaryStep | ||
* Gaussian | ||
* HyperbolicTangent | ||
* Sigmoid (default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters