@Deprecated public abstract class NeuralNetwork extends Object
Modifier and Type | Class and Description |
---|---|
static class |
NeuralNetwork.TrainingMethod
Deprecated.
|
Modifier and Type | Field and Description |
---|---|
protected String |
costFunctionName
Deprecated.
|
static double |
DEFAULT_LEARNING_RATE
Deprecated.
|
static double |
DEFAULT_MOMENTUM_WEIGHT
Deprecated.
|
static double |
DEFAULT_REGULARIZATION_WEIGHT
Deprecated.
|
protected int |
finalLayerIndex
Deprecated.
|
protected List<Integer> |
layerSizeList
Deprecated.
|
protected double |
learningRate
Deprecated.
|
protected String |
modelPath
Deprecated.
|
protected String |
modelType
Deprecated.
|
protected double |
momentumWeight
Deprecated.
|
protected List<Matrix> |
prevWeightUpdatesList
Deprecated.
|
protected double |
regularizationWeight
Deprecated.
|
protected List<String> |
squashingFunctionList
Deprecated.
|
protected NeuralNetwork.TrainingMethod |
trainingMethod
Deprecated.
|
protected List<Matrix> |
weightMatrixList
Deprecated.
|
Constructor and Description |
---|
NeuralNetwork()
Deprecated.
The default constructor that initializes the learning rate, regularization
weight, and momentum weight by default.
|
NeuralNetwork(double learningRate,
double momentumWeight,
double regularizationWeight)
Deprecated.
Initialize the NeuralNetwork by specifying learning rate, momentum weight
and regularization weight.
|
NeuralNetwork(String modelPath)
Deprecated.
Initialize the NeuralNetwork by specifying the location of the model.
|
Modifier and Type | Method and Description |
---|---|
int |
addLayer(int size,
boolean isFinalLayer,
String squashingFunctionName)
Deprecated.
Add a layer of neurons with specified size.
|
protected Vector |
forward(int fromLayer,
Vector intermediateOutput)
Deprecated.
Forward the calculation for one layer.
|
int |
getLayerSize(int layer)
Deprecated.
Get the size of a particular layer.
|
protected List<Integer> |
getLayerSizeList()
Deprecated.
Get the layer size list.
|
double |
getLearningRate()
Deprecated.
Get the value of learning rate.
|
String |
getModelPath()
Deprecated.
Get the model path.
|
String |
getModelType()
Deprecated.
Get the type of the model.
|
double |
getMomentumWeight()
Deprecated.
Get the momentum weight.
|
Vector |
getOutput(Vector instance)
Deprecated.
Get the output calculated by the model.
|
protected List<Vector> |
getOutputInternal(Vector instance)
Deprecated.
Calculate output internally, the intermediate output of each layer will be
stored.
|
double |
getRegularizationWeight()
Deprecated.
Get the weight of the regularization.
|
NeuralNetwork.TrainingMethod |
getTrainingMethod()
Deprecated.
Get the training method.
|
Matrix[] |
getWeightMatrices()
Deprecated.
Get all the weight matrices.
|
Matrix |
getWeightsByLayer(int layerIndex)
Deprecated.
Get the weights between layer layerIndex and layerIndex + 1
|
void |
readFields(DataInput input)
Deprecated.
Read the fields of the model from input.
|
protected void |
readFromModel()
Deprecated.
Read the model meta-data from the specified location.
|
NeuralNetwork |
setCostFunction(String costFunction)
Deprecated.
Set the cost function for the model.
|
NeuralNetwork |
setLearningRate(double learningRate)
Deprecated.
Set the degree of aggression during model training, a large learning rate
can increase the training speed, but it also decreases the chance of model
converge.
|
void |
setModelPath(String modelPath)
Deprecated.
Set the model path.
|
NeuralNetwork |
setMomentumWeight(double momentumWeight)
Deprecated.
Set the momentum weight for the model.
|
NeuralNetwork |
setRegularizationWeight(double regularizationWeight)
Deprecated.
Set the regularization weight.
|
NeuralNetwork |
setTrainingMethod(NeuralNetwork.TrainingMethod method)
Deprecated.
Set the training method.
|
void |
setWeightMatrices(Matrix[] matrices)
Deprecated.
Set the weight matrices.
|
void |
setWeightMatrix(int index,
Matrix matrix)
Deprecated.
Set the weight matrix for a specified layer.
|
Matrix[] |
trainByInstance(Vector trainingInstance)
Deprecated.
Get the updated weights using one training instance.
|
void |
trainOnline(Vector trainingInstance)
Deprecated.
Train the neural network incrementally with given training instance.
|
void |
updateWeightMatrices(Matrix[] matrices)
Deprecated.
Update the weight matrices with given matrices.
|
void |
write(DataOutput output)
Deprecated.
Write the fields of the model to output.
|
void |
writeModelToFile()
Deprecated.
Write the model data to specified location.
|
public static final double DEFAULT_LEARNING_RATE
public static final double DEFAULT_REGULARIZATION_WEIGHT
public static final double DEFAULT_MOMENTUM_WEIGHT
protected String modelType
protected String modelPath
protected double learningRate
protected double regularizationWeight
protected double momentumWeight
protected String costFunctionName
protected NeuralNetwork.TrainingMethod trainingMethod
protected int finalLayerIndex
public NeuralNetwork()
public NeuralNetwork(double learningRate, double momentumWeight, double regularizationWeight)
learningRate
- The learning rate.momentumWeight
- The momentum weight.regularizationWeight
- The regularization weight.public NeuralNetwork(String modelPath) throws IOException
modelPath
- The location that the model is stored.IOException
public String getModelType()
public final NeuralNetwork setLearningRate(double learningRate)
learningRate
- Learning rate must be a non-negative value. Recommend in range (0, 0.5).public double getLearningRate()
public final NeuralNetwork setRegularizationWeight(double regularizationWeight)
regularizationWeight
- regularization must be in the range [0, 0.1).public double getRegularizationWeight()
public final NeuralNetwork setMomentumWeight(double momentumWeight)
momentumWeight
- momentumWeight must be in range [0, 0.5].public double getMomentumWeight()
public NeuralNetwork setTrainingMethod(NeuralNetwork.TrainingMethod method)
method
- The training method, currently supports GRADIENT_DESCENT.public NeuralNetwork.TrainingMethod getTrainingMethod()
public NeuralNetwork setCostFunction(String costFunction)
costFunction
- the name of the cost function. Currently supports
"Minus_Squared", "Cross_Entropy".public int addLayer(int size, boolean isFinalLayer, String squashingFunctionName)
size
- The size of the layer. (bias neuron excluded)isFinalLayer
- If false, add a bias neuron.squashingFunctionName
- The squashing function for this layer, input
layer is f(x) = x by default.public int getLayerSize(int layer)
layer
- The index of the layer, starting from 0.protected List<Integer> getLayerSizeList()
public Matrix getWeightsByLayer(int layerIndex)
layerIndex
- The index of the layer.Matrix
.public void updateWeightMatrices(Matrix[] matrices)
matrices
- The weight matrices, must be the same dimension as the
existing matrices.public void setWeightMatrices(Matrix[] matrices)
matrices
- The weight matrices, must be the same dimension of the
existing matrices.public void setWeightMatrix(int index, Matrix matrix)
index
- The index of the matrix, starting from 0 (between layer 0 and 1).matrix
- The instance of Matrix
.public Matrix[] getWeightMatrices()
public Vector getOutput(Vector instance)
instance
- The feature instance in form of Vector
, each dimension contains the value of the corresponding feature.protected List<Vector> getOutputInternal(Vector instance)
instance
- The feature instance in form of Vector
, each dimension contains the value of the corresponding feature.protected Vector forward(int fromLayer, Vector intermediateOutput)
fromLayer
- The index of the previous layer.intermediateOutput
- The intermediate output of previous layer.public void trainOnline(Vector trainingInstance)
trainingInstance
- An training instance, including the features and the label(s). Its dimension must equals
to the size of the input layer (bias neuron excluded) + the size
of the output layer (a.k.a. the dimension of the labels).public Matrix[] trainByInstance(Vector trainingInstance)
trainingInstance
- An training instance, including the features and the label(s). Its dimension must equals
to the size of the input layer (bias neuron excluded) + the size
of the output layer (a.k.a. the dimension of the labels).Matrix
list.protected void readFromModel() throws IOException
IOException
public void writeModelToFile() throws IOException
IOException
public void setModelPath(String modelPath)
modelPath
- The path of the model.public String getModelPath()
public void write(DataOutput output) throws IOException
output
- The output instance.IOException
public void readFields(DataInput input) throws IOException
input
- The input instance.IOException
Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.