public final class MultilayerPerceptron extends Object implements IgniteModel<Matrix,Matrix>, SmoothParametrized<MultilayerPerceptron>, Serializable
Modifier and Type | Field and Description |
---|---|
protected MLPArchitecture |
architecture
This MLP architecture.
|
protected MultilayerPerceptron |
below
MLP which is 'below' this MLP (i.e. below output goes to this MLP as input).
|
protected List<MLPLayer> |
layers
List containing layers parameters.
|
Modifier | Constructor and Description |
---|---|
|
MultilayerPerceptron(MLPArchitecture arch)
Construct MLP from given architecture.
|
|
MultilayerPerceptron(MLPArchitecture arch,
MLPInitializer initializer)
Construct MLP from given architecture and parameters initializer.
|
protected |
MultilayerPerceptron(MultilayerPerceptron above,
MultilayerPerceptron below)
Create MLP from two MLPs: first stacked on second.
|
Modifier and Type | Method and Description |
---|---|
MultilayerPerceptron |
add(MultilayerPerceptron above)
Create MLP where this MLP output is fed as input to added MLP.
|
MLPArchitecture |
architecture()
Get architecture of this MLP.
|
protected int |
belowLayersCount()
Count of layers in below MLP.
|
double |
bias(int layerIdx,
int neuronIdx)
Get the bias of given neuron in given layer.
|
Vector |
biases(int layerIdx)
Get biases of layer with given index.
|
MLPState |
computeState(Matrix val)
Perform forward pass and return state of outputs of each layer.
|
Vector |
differentiateByParameters(IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss,
Matrix inputsBatch,
Matrix truthBatch)
Compose function in the following way: feed output of this model as input to second argument to loss function.
|
Matrix |
forwardPass(Matrix val,
MLPState state,
boolean writeState)
Perform forward pass and if needed write state of outputs of each layer.
|
boolean |
hasBiases(int layerIdx)
Checks if layer with given index has biases.
|
int |
layersCount()
Get count of layers in this MLP.
|
Vector |
parameters()
Get parameters vector.
|
int |
parametersCount()
Get count of parameters of this model.
|
protected Vector |
paramsAsVector(List<MLPLayer> layersParams)
Flatten this MLP parameters as vector.
|
Matrix |
predict(Matrix val)
Makes a prediction for the given objects.
|
MultilayerPerceptron |
setBias(int layerIdx,
int neuronIdx,
double val)
Set the bias of given neuron in given layer.
|
MultilayerPerceptron |
setBiases(int layerIdx,
Vector bias)
Sets the biases of layer with a given index.
|
MultilayerPerceptron |
setParameters(Vector vector)
Set parameters.
|
MultilayerPerceptron |
setWeight(int layerIdx,
int fromNeuron,
int toNeuron,
double val)
Set the weight of neuron with given index in previous layer to neuron with given index in given layer.
|
MultilayerPerceptron |
setWeights(int layerIdx,
Matrix weights)
Sets the weighs of layer with a given index.
|
String |
toString() |
String |
toString(boolean pretty) |
double |
weight(int layerIdx,
int fromNeuron,
int toNeuron)
Get the weight of neuron with given index in previous layer to neuron with given index in given layer.
|
Matrix |
weights(int layerIdx)
Get weights of layer with given index.
|
default M |
withParameters(Vector vector)
Return new model with given parameters vector.
|
protected MLPArchitecture architecture
protected MultilayerPerceptron below
public MultilayerPerceptron(MLPArchitecture arch, MLPInitializer initializer)
arch
- Architecture.initializer
- Parameters initializer.public MultilayerPerceptron(MLPArchitecture arch)
arch
- Architecture.protected MultilayerPerceptron(MultilayerPerceptron above, MultilayerPerceptron below)
above
- MLP to be above.below
- MLP to be below.public MLPState computeState(Matrix val)
val
- Value to perform computation on.public Matrix forwardPass(Matrix val, MLPState state, boolean writeState)
val
- Value to perform computation on.state
- State object to write state into.writeState
- Flag indicating need to write state.public MultilayerPerceptron add(MultilayerPerceptron above)
above
- Added MLP.public Matrix weights(int layerIdx)
layerIdx
- Layer index.public Vector biases(int layerIdx)
layerIdx
- Layer index.public boolean hasBiases(int layerIdx)
layerIdx
- Layer index.public MultilayerPerceptron setBiases(int layerIdx, Vector bias)
layerIdx
- Layer index.bias
- New values for biases.public MultilayerPerceptron setBias(int layerIdx, int neuronIdx, double val)
layerIdx
- Layer index.neuronIdx
- Neuron index.val
- New value of bias.public double bias(int layerIdx, int neuronIdx)
layerIdx
- Layer index.neuronIdx
- Neuron index.public MultilayerPerceptron setWeights(int layerIdx, Matrix weights)
layerIdx
- Layer index.weights
- New values for weights.public MultilayerPerceptron setWeight(int layerIdx, int fromNeuron, int toNeuron, double val)
layerIdx
- Layer index.fromNeuron
- Neuron index in previous layer.toNeuron
- Neuron index in current layer.val
- New value of weight.public double weight(int layerIdx, int fromNeuron, int toNeuron)
layerIdx
- Layer index.fromNeuron
- Neuron index in previous layer.toNeuron
- Neuron index in current layer.public int layersCount()
protected int belowLayersCount()
public MLPArchitecture architecture()
public Vector differentiateByParameters(IgniteFunction<Vector,IgniteDifferentiableVectorToDoubleFunction> loss, Matrix inputsBatch, Matrix truthBatch)
differentiateByParameters
in interface SmoothParametrized<MultilayerPerceptron>
loss
- Loss function.inputsBatch
- Batch of inputs.truthBatch
- Batch of ground truths.public Vector parameters()
protected Vector paramsAsVector(List<MLPLayer> layersParams)
layersParams
- List of layers parameters.public MultilayerPerceptron setParameters(Vector vector)
vector
- Parameters vector.public int parametersCount()
public String toString(boolean pretty)
toString
in interface IgniteModel<Matrix,Matrix>
pretty
- Use pretty mode.public M withParameters(Vector vector)
vector
- Parameters vector.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024