Constructor
new Net(argmap)
Creates a neural network.
-
The
argmap
can have the single propertylayers
(the size of each layer). In this case a random neural network is created. -
The
argmap
can have the single propertyjson
(the JSON representation of a neural network). In this case a specific neural network is created. -
The
argmap
can have the propertieslayers
andseed
(the number used to initialize the internal pseudorandom number generator). In this case a non-random neural network is created. -
The
argmap
can have the propertieslayers
,activation
(the function that accepts the index of a layer and returns an activation function for its neurons) andweight
(the function that accepts the index of a layer and returns a weight for the synapses of its neurons). In this case a customized neural network is created.
Parameters:
Name | Type | Description |
---|---|---|
argmap |
An object that hold the parameters for the constructor. |
Methods
fit(learningRate, inputValues, expectedOutput)
Adjust the weights of the neural network to the provided observation.
In order for it to be trained, it should fit with multiple observations.
Parameters:
Name | Type | Description |
---|---|---|
learningRate |
A number that controls how much the weights are adjusted to the observation. |
|
inputValues |
The feature values of the observation. |
|
expectedOutput |
The expected output of the observation. It's size should be equal to the size of the output layer. |
json()
The JSON representation of the neural network.
Returns:
The JSON representation of the neural network.
predict(inputValues)
Makes a prediction for the provided input.
Parameters:
Name | Type | Description |
---|---|---|
inputValues |
The values of the features. Their size should be equal to the size of the input layer. |
Returns:
The prediction. It's size should be equal to the size of the output layer.
svg()
An SVG representation of the neural network.
Returns:
The SVG representation of the neural network. The color of each neuron depends on its activation function while the transparency of the synapses depends on their weight.