public class OutputLayer extends BaseLayer implements Serializable, Classifier
Modifier and Type | Class and Description |
---|---|
static class |
OutputLayer.Builder |
Constructor and Description |
---|
OutputLayer(NeuralNetConfiguration conf,
org.nd4j.linalg.api.ndarray.INDArray input,
org.nd4j.linalg.api.ndarray.INDArray labels) |
Modifier and Type | Method and Description |
---|---|
Layer |
clone() |
void |
fit(org.nd4j.linalg.dataset.api.DataSet data)
Fit the model
|
void |
fit(org.nd4j.linalg.dataset.api.DataSet data,
Object[] params)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray data)
Fit the model to the given data
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray examples,
org.nd4j.linalg.api.ndarray.INDArray labels)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray examples,
org.nd4j.linalg.api.ndarray.INDArray labels,
Object[] params)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray examples,
int[] labels)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray examples,
int[] labels,
Object[] params)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray data,
Object[] params)
Fit the model to the given data
|
org.nd4j.linalg.learning.AdaGrad |
getAdaGrad() |
org.nd4j.linalg.learning.AdaGrad |
getBiasAdaGrad() |
OutputLayerGradient |
getGradient(double lr)
Gets the gradient from one training iteration
|
org.nd4j.linalg.api.ndarray.INDArray |
getLabels() |
void |
iterate(org.nd4j.linalg.api.ndarray.INDArray examples,
int[] labels,
Object[] params)
Iterate once on the model
|
void |
iterate(org.nd4j.linalg.api.ndarray.INDArray input,
Object[] params)
Run one iteration
|
org.nd4j.linalg.api.ndarray.INDArray |
labelProbabilities(org.nd4j.linalg.api.ndarray.INDArray examples)
Returns the probabilities for each label
for each example row wise
|
int |
numLabels()
Returns the number of possible labels
|
int |
numParams()
The number of parameters for the model
|
org.nd4j.linalg.api.ndarray.INDArray |
output(org.nd4j.linalg.api.ndarray.INDArray x)
Classify input
|
org.nd4j.linalg.api.ndarray.INDArray |
params()
Returns the coefficients for this classifier as a raveled vector
|
int[] |
predict(org.nd4j.linalg.api.ndarray.INDArray d)
Returns the predictions for each example in the dataset
|
double |
score()
Objective function: the specified objective
|
double |
score(org.nd4j.linalg.dataset.api.DataSet data)
Sets the input and labels and returns a score for the prediction
wrt true labels
|
double |
score(org.nd4j.linalg.api.ndarray.INDArray examples,
org.nd4j.linalg.api.ndarray.INDArray labels)
Returns the f1 score for the given examples.
|
void |
setAdaGrad(org.nd4j.linalg.learning.AdaGrad adaGrad) |
void |
setBiasAdaGrad(org.nd4j.linalg.learning.AdaGrad biasAdaGrad) |
void |
setLabels(org.nd4j.linalg.api.ndarray.INDArray labels) |
void |
setParams(org.nd4j.linalg.api.ndarray.INDArray params)
Set the parameters for this model.
|
String |
toString() |
void |
train(double lr)
Train with current input and labels
with the given learning rate
|
void |
train(org.nd4j.linalg.api.ndarray.INDArray x,
double lr)
Train with the given input
and the currently applyTransformToDestination labels
|
void |
train(org.nd4j.linalg.api.ndarray.INDArray x,
org.nd4j.linalg.api.ndarray.INDArray y,
double lr)
Train on the given inputs and labels.
|
void |
trainTillConvergence(double learningRate,
int numEpochs)
Run conjugate gradient
|
void |
trainTillConvergence(double learningRate,
int numEpochs,
TrainingEvaluator eval)
Run the optimization algorithm for training
|
void |
trainTillConvergence(org.nd4j.linalg.api.ndarray.INDArray labels,
double learningRate,
int numEpochs,
TrainingEvaluator eval)
Run the optimization algorithm for training
|
void |
trainTillConvergence(org.nd4j.linalg.api.ndarray.INDArray x,
org.nd4j.linalg.api.ndarray.INDArray y,
double learningRate,
int epochs)
Run conjugate gradient with the given x and y
|
org.nd4j.linalg.api.ndarray.INDArray |
transform(org.nd4j.linalg.api.ndarray.INDArray data)
Transform the data based on the model's output.
|
activate, activate, activationMean, applyDropOutIfNecessary, conf, createBias, createWeightMatrix, getB, getInput, getW, merge, preOutput, setB, setConfiguration, setInput, setW, transpose
public OutputLayer(NeuralNetConfiguration conf, org.nd4j.linalg.api.ndarray.INDArray input, org.nd4j.linalg.api.ndarray.INDArray labels)
public void train(double lr)
lr
- the learning rate to usepublic void train(org.nd4j.linalg.api.ndarray.INDArray x, double lr)
x
- the input to uselr
- the learning rate to usepublic void trainTillConvergence(org.nd4j.linalg.api.ndarray.INDArray x, org.nd4j.linalg.api.ndarray.INDArray y, double learningRate, int epochs)
x
- the input to usey
- the labels to uselearningRate
- epochs
- public void trainTillConvergence(org.nd4j.linalg.api.ndarray.INDArray labels, double learningRate, int numEpochs, TrainingEvaluator eval)
learningRate
- the learning rate to iterate withnumEpochs
- the number of epochseval
- the training evaluator to use for early stopping (where applicable)public void trainTillConvergence(double learningRate, int numEpochs, TrainingEvaluator eval)
learningRate
- the learning rate to iterate withnumEpochs
- the number of epochseval
- the training evaluator to use for early stopping (where applicable)public void trainTillConvergence(double learningRate, int numEpochs)
learningRate
- the learning rate to iterate withnumEpochs
- the number of epochspublic double score()
score
in interface Classifier
score
in interface Model
public void train(org.nd4j.linalg.api.ndarray.INDArray x, org.nd4j.linalg.api.ndarray.INDArray y, double lr)
x
- the inputs to iterate ony
- the labels to iterate onlr
- the learning ratepublic Layer clone()
public OutputLayerGradient getGradient(double lr)
lr
- the learning rate to use for trainingpublic double score(org.nd4j.linalg.dataset.api.DataSet data)
score
in interface Classifier
data
- the data to scorepublic double score(org.nd4j.linalg.api.ndarray.INDArray examples, org.nd4j.linalg.api.ndarray.INDArray labels)
score
in interface Classifier
examples
- te the examples to classify (one example in each row)labels
- the true labelspublic int numLabels()
numLabels
in interface Classifier
public int[] predict(org.nd4j.linalg.api.ndarray.INDArray d)
predict
in interface Classifier
d
- the matrix to predictpublic org.nd4j.linalg.api.ndarray.INDArray labelProbabilities(org.nd4j.linalg.api.ndarray.INDArray examples)
labelProbabilities
in interface Classifier
examples
- the examples to classify (one example in each row)public void fit(org.nd4j.linalg.api.ndarray.INDArray examples, org.nd4j.linalg.api.ndarray.INDArray labels)
fit
in interface Classifier
examples
- the examples to classify (one example in each row)labels
- the example labels(a binary outcome matrix)public void fit(org.nd4j.linalg.dataset.api.DataSet data)
fit
in interface Classifier
data
- the data to train onpublic void fit(org.nd4j.linalg.api.ndarray.INDArray examples, org.nd4j.linalg.api.ndarray.INDArray labels, Object[] params)
fit
in interface Classifier
examples
- the examples to classify (one example in each row)labels
- the example labels(a binary outcome matrix)params
- extra parameterspublic void fit(org.nd4j.linalg.dataset.api.DataSet data, Object[] params)
fit
in interface Classifier
data
- the data to train onparams
- extra parameterspublic void fit(org.nd4j.linalg.api.ndarray.INDArray examples, int[] labels)
fit
in interface Classifier
examples
- the examples to classify (one example in each row)labels
- the labels for each example (the number of labels must matchpublic void fit(org.nd4j.linalg.api.ndarray.INDArray examples, int[] labels, Object[] params)
fit
in interface Classifier
examples
- the examples to classify (one example in each row)labels
- the labels for each example (the number of labels must match
the number of rows in the exampleparams
- extra parameterspublic void iterate(org.nd4j.linalg.api.ndarray.INDArray examples, int[] labels, Object[] params)
iterate
in interface Classifier
examples
- the examples to classify (one example in each row)labels
- the labels for each example (the number of labels must match
the number of rows in the exampleparams
- extra parameterspublic org.nd4j.linalg.api.ndarray.INDArray transform(org.nd4j.linalg.api.ndarray.INDArray data)
public org.nd4j.linalg.api.ndarray.INDArray params()
public int numParams()
public void setParams(org.nd4j.linalg.api.ndarray.INDArray params)
public void fit(org.nd4j.linalg.api.ndarray.INDArray data, Object[] params)
public void fit(org.nd4j.linalg.api.ndarray.INDArray data)
public void iterate(org.nd4j.linalg.api.ndarray.INDArray input, Object[] params)
public org.nd4j.linalg.api.ndarray.INDArray output(org.nd4j.linalg.api.ndarray.INDArray x)
x
- the input (can either be a matrix or vector)
If it's a matrix, each row is considered an example
and associated rows are classified accordingly.
Each row will be the likelihood of a label given that examplepublic org.nd4j.linalg.api.ndarray.INDArray getLabels()
public void setLabels(org.nd4j.linalg.api.ndarray.INDArray labels)
public org.nd4j.linalg.learning.AdaGrad getBiasAdaGrad()
public org.nd4j.linalg.learning.AdaGrad getAdaGrad()
public void setAdaGrad(org.nd4j.linalg.learning.AdaGrad adaGrad)
public void setBiasAdaGrad(org.nd4j.linalg.learning.AdaGrad biasAdaGrad)
Copyright © 2014. All rights reserved.