public abstract class BaseOutputLayer<LayerConfT extends BaseOutputLayer> extends BaseLayer<LayerConfT> implements Serializable, Classifier
Layer.TrainingMode, Layer.Type| Modifier and Type | Field and Description |
|---|---|
protected org.nd4j.linalg.api.ndarray.INDArray |
labels |
conf, dropoutApplied, dropoutMask, gradient, gradientsFlattened, gradientViews, index, input, iterationListeners, maskArray, optimizer, params, paramsFlattened, score| Constructor and Description |
|---|
BaseOutputLayer(NeuralNetConfiguration conf) |
BaseOutputLayer(NeuralNetConfiguration conf,
org.nd4j.linalg.api.ndarray.INDArray input) |
| Modifier and Type | Method and Description |
|---|---|
org.nd4j.linalg.api.ndarray.INDArray |
activate()
Trigger an activation with the last specified input
|
org.nd4j.linalg.api.ndarray.INDArray |
activate(org.nd4j.linalg.api.ndarray.INDArray input)
Initialize the layer with the given input
and return the activation for this layer
given this input
|
org.nd4j.linalg.api.ndarray.INDArray |
activate(org.nd4j.linalg.api.ndarray.INDArray input,
boolean training)
Initialize the layer with the given input
and return the activation for this layer
given this input
|
Pair<Gradient,org.nd4j.linalg.api.ndarray.INDArray> |
backpropGradient(org.nd4j.linalg.api.ndarray.INDArray epsilon)
Calculate the gradient relative to the error in the next layer
|
void |
clear()
Clear input
|
void |
computeGradientAndScore()
Update the score
|
double |
computeScore(double fullNetworkL1,
double fullNetworkL2,
boolean training)
Compute score after labels and input have been set.
|
org.nd4j.linalg.api.ndarray.INDArray |
computeScoreForExamples(double fullNetworkL1,
double fullNetworkL2)
Compute the score for each example individually, after labels and input have been set.
|
double |
f1Score(org.nd4j.linalg.dataset.api.DataSet data)
Sets the input and labels and returns a score for the prediction
wrt true labels
|
double |
f1Score(org.nd4j.linalg.api.ndarray.INDArray examples,
org.nd4j.linalg.api.ndarray.INDArray labels)
Returns the f1 score for the given examples.
|
void |
fit(org.nd4j.linalg.dataset.api.DataSet data)
Fit the model
|
void |
fit(org.nd4j.linalg.dataset.api.iterator.DataSetIterator iter)
Train the model based on the datasetiterator
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray data)
Fit the model to the given data
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray input,
org.nd4j.linalg.api.ndarray.INDArray labels)
Fit the model
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray examples,
int[] labels)
Fit the model
|
org.nd4j.linalg.api.ndarray.INDArray |
getLabels() |
protected org.nd4j.linalg.api.ndarray.INDArray |
getLabels2d() |
Gradient |
gradient()
Gets the gradient from one training iteration
|
Pair<Gradient,Double> |
gradientAndScore()
Get the gradient and score
|
void |
iterate(org.nd4j.linalg.api.ndarray.INDArray input)
iterate one iteration of the network
|
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
|
org.nd4j.linalg.api.ndarray.INDArray |
output(boolean training)
Classify input
|
org.nd4j.linalg.api.ndarray.INDArray |
output(org.nd4j.linalg.api.ndarray.INDArray input) |
org.nd4j.linalg.api.ndarray.INDArray |
output(org.nd4j.linalg.api.ndarray.INDArray input,
boolean training) |
protected org.nd4j.linalg.api.ndarray.INDArray |
output2d(org.nd4j.linalg.api.ndarray.INDArray input) |
List<String> |
predict(org.nd4j.linalg.dataset.api.DataSet dataSet)
Return predicted label names
|
int[] |
predict(org.nd4j.linalg.api.ndarray.INDArray input)
Returns the predictions for each example in the dataset
|
protected org.nd4j.linalg.api.ndarray.INDArray |
preOutput2d(boolean training) |
void |
setLabels(org.nd4j.linalg.api.ndarray.INDArray labels) |
protected void |
setScoreWithZ(org.nd4j.linalg.api.ndarray.INDArray z) |
accumulateScore, activate, activate, activate, activationMean, applyDropOutIfNecessary, applyLearningRateScoreDecay, batchSize, calcGradient, calcL1, calcL2, clone, conf, createGradient, derivativeActivation, error, fit, getIndex, getInput, getInputMiniBatchSize, getListeners, getOptimizer, getParam, initParams, input, layerConf, merge, numParams, numParams, params, paramTable, preOutput, preOutput, preOutput, preOutput, score, setBackpropGradientsViewArray, setConf, setIndex, setInput, setInputMiniBatchSize, setListeners, setListeners, setMaskArray, setParam, setParams, setParams, setParamsViewArray, setParamTable, toString, transpose, type, update, update, validateInputequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaccumulateScore, applyLearningRateScoreDecay, batchSize, conf, fit, getOptimizer, getParam, initParams, input, numParams, numParams, params, paramTable, score, setBackpropGradientsViewArray, setConf, setParam, setParams, setParamsViewArray, setParamTable, update, validateInputpublic BaseOutputLayer(NeuralNetConfiguration conf)
public BaseOutputLayer(NeuralNetConfiguration conf, org.nd4j.linalg.api.ndarray.INDArray input)
public double computeScore(double fullNetworkL1,
double fullNetworkL2,
boolean training)
fullNetworkL1 - L1 regularization term for the entire networkfullNetworkL2 - L2 regularization term for the entire networktraining - whether score should be calculated at train or test time (this affects things like application of
dropout, etc)public org.nd4j.linalg.api.ndarray.INDArray computeScoreForExamples(double fullNetworkL1,
double fullNetworkL2)
fullNetworkL1 - L1 regularization term for the entire network (or, 0.0 to not include regularization)fullNetworkL2 - L2 regularization term for the entire network (or, 0.0 to not include regularization)public void computeGradientAndScore()
ModelcomputeGradientAndScore in interface ModelcomputeGradientAndScore in class BaseLayer<LayerConfT extends BaseOutputLayer>protected void setScoreWithZ(org.nd4j.linalg.api.ndarray.INDArray z)
setScoreWithZ in class BaseLayer<LayerConfT extends BaseOutputLayer>public Pair<Gradient,Double> gradientAndScore()
ModelgradientAndScore in interface ModelgradientAndScore in class BaseLayer<LayerConfT extends BaseOutputLayer>public Pair<Gradient,org.nd4j.linalg.api.ndarray.INDArray> backpropGradient(org.nd4j.linalg.api.ndarray.INDArray epsilon)
LayerbackpropGradient in interface LayerbackpropGradient in class BaseLayer<LayerConfT extends BaseOutputLayer>epsilon - w^(L+1)*delta^(L+1). Or, equiv: dC/da, i.e., (dC/dz)*(dz/da) = dC/da, where C
is cost function a=sigma(z) is activation.public Gradient gradient()
gradient in interface Modelgradient in class BaseLayer<LayerConfT extends BaseOutputLayer>public org.nd4j.linalg.api.ndarray.INDArray activate(org.nd4j.linalg.api.ndarray.INDArray input,
boolean training)
Layeractivate in interface Layeractivate in class BaseLayer<LayerConfT extends BaseOutputLayer>input - the input to usetraining - train or test modepublic org.nd4j.linalg.api.ndarray.INDArray activate(org.nd4j.linalg.api.ndarray.INDArray input)
Layeractivate in interface Layeractivate in class BaseLayer<LayerConfT extends BaseOutputLayer>input - the input to usepublic org.nd4j.linalg.api.ndarray.INDArray activate()
Layeractivate in interface Layeractivate in class BaseLayer<LayerConfT extends BaseOutputLayer>public org.nd4j.linalg.api.ndarray.INDArray output(org.nd4j.linalg.api.ndarray.INDArray input,
boolean training)
public org.nd4j.linalg.api.ndarray.INDArray output(org.nd4j.linalg.api.ndarray.INDArray input)
public org.nd4j.linalg.api.ndarray.INDArray output(boolean training)
training - determines if its training
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 double f1Score(org.nd4j.linalg.dataset.api.DataSet data)
f1Score in interface Classifierdata - the data to scorepublic double f1Score(org.nd4j.linalg.api.ndarray.INDArray examples,
org.nd4j.linalg.api.ndarray.INDArray labels)
f1Score in interface Classifierexamples - te the examples to classify (one example in each row)labels - the true labelspublic int numLabels()
numLabels in interface Classifierpublic void fit(org.nd4j.linalg.dataset.api.iterator.DataSetIterator iter)
Classifierfit in interface Classifieriter - the iterator to train onpublic int[] predict(org.nd4j.linalg.api.ndarray.INDArray input)
predict in interface Classifierinput - the matrix to predictpublic List<String> predict(org.nd4j.linalg.dataset.api.DataSet dataSet)
predict in interface ClassifierdataSet - to predictpublic org.nd4j.linalg.api.ndarray.INDArray labelProbabilities(org.nd4j.linalg.api.ndarray.INDArray examples)
labelProbabilities in interface Classifierexamples - the examples to classify (one example in each row)public void fit(org.nd4j.linalg.api.ndarray.INDArray input,
org.nd4j.linalg.api.ndarray.INDArray labels)
fit in interface Classifierinput - 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 Classifierdata - the data to train onpublic void fit(org.nd4j.linalg.api.ndarray.INDArray examples,
int[] labels)
fit in interface Classifierexamples - the examples to classify (one example in each row)labels - the labels for each example (the number of labels must matchpublic void clear()
Modelclear in interface Modelclear in class BaseLayer<LayerConfT extends BaseOutputLayer>public void fit(org.nd4j.linalg.api.ndarray.INDArray data)
fit in interface Modelfit in class BaseLayer<LayerConfT extends BaseOutputLayer>data - the data to fit the model topublic void iterate(org.nd4j.linalg.api.ndarray.INDArray input)
BaseLayeriterate in interface Modeliterate in class BaseLayer<LayerConfT extends BaseOutputLayer>input - the input to iterate onpublic org.nd4j.linalg.api.ndarray.INDArray getLabels()
public void setLabels(org.nd4j.linalg.api.ndarray.INDArray labels)
protected org.nd4j.linalg.api.ndarray.INDArray preOutput2d(boolean training)
protected org.nd4j.linalg.api.ndarray.INDArray output2d(org.nd4j.linalg.api.ndarray.INDArray input)
protected org.nd4j.linalg.api.ndarray.INDArray getLabels2d()
Copyright © 2016. All Rights Reserved.