public abstract class BaseLayer extends Object implements Layer
Layer.Type
Modifier and Type | Field and Description |
---|---|
protected NeuralNetConfiguration |
conf |
protected org.nd4j.linalg.api.ndarray.INDArray |
dropoutMask |
protected org.nd4j.linalg.api.ndarray.INDArray |
input |
protected Collection<IterationListener> |
iterationListeners |
protected ConvexOptimizer |
optimizer |
protected ParamInitializer |
paramInitializer |
protected Map<String,org.nd4j.linalg.api.ndarray.INDArray> |
params |
protected double |
score |
Constructor and Description |
---|
BaseLayer(NeuralNetConfiguration conf) |
BaseLayer(NeuralNetConfiguration conf,
org.nd4j.linalg.api.ndarray.INDArray input) |
Modifier and Type | Method and Description |
---|---|
void |
accumulateScore(double accum)
Sets a rolling tally for the score.
|
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 |
activationMean()
Calculate the mean representation
for the activation for this layer
|
protected void |
applyDropOutIfNecessary(org.nd4j.linalg.api.ndarray.INDArray input) |
Pair<Gradient,Gradient> |
backWard(Gradient ixes,
Gradient deltas,
org.nd4j.linalg.api.ndarray.INDArray activation,
String previousActivation)
Propagate errors backwards for a particular layer.
|
Gradient |
backwardGradient(org.nd4j.linalg.api.ndarray.INDArray activation,
Gradient errorSignal)
Calculate the gradient relative to the
error in the next layer
|
int |
batchSize()
The current inputs batch size
|
Gradient |
calcGradient(Gradient layerError,
org.nd4j.linalg.api.ndarray.INDArray activation)
Calculate the gradient
|
void |
clear()
Clear input
|
Layer |
clone()
Clone the layer
|
NeuralNetConfiguration |
conf()
The configuration for the neural network
|
protected Gradient |
createGradient(org.nd4j.linalg.api.ndarray.INDArray... gradients)
Create a gradient list based on the passed in parameters.
|
org.nd4j.linalg.api.ndarray.INDArray |
derivativeActivation(org.nd4j.linalg.api.ndarray.INDArray input)
Take the derivative of the given input
based on the activation
|
Gradient |
error(org.nd4j.linalg.api.ndarray.INDArray errorSignal)
Calculate error with respect to the
current layer.
|
Gradient |
errorSignal(Gradient error,
org.nd4j.linalg.api.ndarray.INDArray input)
Error signal for this layer
Using the amount of error
caused by this layer
calculate the error signal used
as input in to the next layer.
|
void |
fit()
All models have a fit method
|
void |
fit(org.nd4j.linalg.api.ndarray.INDArray input)
Fit the model to the given data
|
Collection<IterationListener> |
getIterationListeners()
Get the iteration listeners for this layer.
|
ConvexOptimizer |
getOptimizer()
Returns this models optimizer
|
org.nd4j.linalg.api.ndarray.INDArray |
getParam(String param)
Get the parameter
|
Pair<Gradient,Double> |
gradientAndScore()
Get the gradient and score
|
void |
initParams()
Initialize the parameters
|
org.nd4j.linalg.api.ndarray.INDArray |
input()
The input/feature matrix for the model
|
void |
iterate(org.nd4j.linalg.api.ndarray.INDArray input)
iterate one iteration of the network
|
void |
merge(Layer l,
int batchSize)
Averages the given logistic regression
from a mini batch in to this one
|
int |
numParams()
The number of parameters for the model
|
org.nd4j.linalg.api.ndarray.INDArray |
params()
Returns the parameters of the neural network
|
Map<String,org.nd4j.linalg.api.ndarray.INDArray> |
paramTable()
The param table
|
org.nd4j.linalg.api.ndarray.INDArray |
preOutput(org.nd4j.linalg.api.ndarray.INDArray x)
Classify input
|
double |
score()
The score for the model
|
void |
setConf(NeuralNetConfiguration conf)
Setter for the configuration
|
void |
setIterationListeners(Collection<IterationListener> listeners)
Set the iteration listeners for this layer.
|
void |
setParam(String key,
org.nd4j.linalg.api.ndarray.INDArray val)
Set the parameter with a new ndarray
|
void |
setParams(org.nd4j.linalg.api.ndarray.INDArray params)
Set the parameters for this model.
|
void |
setParamTable(Map<String,org.nd4j.linalg.api.ndarray.INDArray> paramTable)
Setter for the param table
|
void |
setScore()
Update the score
|
Layer |
transpose()
Return a transposed copy of the weights/bias
(this means reverse the number of inputs and outputs on the weights)
|
Layer.Type |
type()
Returns the layer type
|
void |
update(Gradient gradient)
Perform one update applying the gradient
|
void |
validateInput()
Validate the input
|
protected org.nd4j.linalg.api.ndarray.INDArray input
protected NeuralNetConfiguration conf
protected org.nd4j.linalg.api.ndarray.INDArray dropoutMask
protected ParamInitializer paramInitializer
protected double score
protected ConvexOptimizer optimizer
protected Collection<IterationListener> iterationListeners
public BaseLayer(NeuralNetConfiguration conf)
public BaseLayer(NeuralNetConfiguration conf, org.nd4j.linalg.api.ndarray.INDArray input)
public Collection<IterationListener> getIterationListeners()
Layer
getIterationListeners
in interface Layer
public void setIterationListeners(Collection<IterationListener> listeners)
Layer
setIterationListeners
in interface Layer
public Gradient error(org.nd4j.linalg.api.ndarray.INDArray errorSignal)
Layer
public org.nd4j.linalg.api.ndarray.INDArray derivativeActivation(org.nd4j.linalg.api.ndarray.INDArray input)
Layer
derivativeActivation
in interface Layer
input
- the input to take the derivative ofpublic Gradient errorSignal(Gradient error, org.nd4j.linalg.api.ndarray.INDArray input)
Layer
errorSignal
in interface Layer
public Gradient calcGradient(Gradient layerError, org.nd4j.linalg.api.ndarray.INDArray activation)
Layer
calcGradient
in interface Layer
layerError
- the layer errorpublic Gradient backwardGradient(org.nd4j.linalg.api.ndarray.INDArray activation, Gradient errorSignal)
Layer
backwardGradient
in interface Layer
activation
- the activation from the networkerrorSignal
- the error signal caused by this network.public void fit()
Model
public void setScore()
Model
public void iterate(org.nd4j.linalg.api.ndarray.INDArray input)
public void update(Gradient gradient)
Model
public ConvexOptimizer getOptimizer()
Model
getOptimizer
in interface Model
public void setConf(NeuralNetConfiguration conf)
Model
public void setParam(String key, org.nd4j.linalg.api.ndarray.INDArray val)
Model
public org.nd4j.linalg.api.ndarray.INDArray params()
public void setParams(org.nd4j.linalg.api.ndarray.INDArray params)
Model
public void initParams()
Model
initParams
in interface Model
public Map<String,org.nd4j.linalg.api.ndarray.INDArray> paramTable()
Model
paramTable
in interface Model
public void setParamTable(Map<String,org.nd4j.linalg.api.ndarray.INDArray> paramTable)
Model
setParamTable
in interface Model
public org.nd4j.linalg.api.ndarray.INDArray getParam(String param)
Model
public org.nd4j.linalg.api.ndarray.INDArray preOutput(org.nd4j.linalg.api.ndarray.INDArray x)
preOutput
in interface Layer
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 int batchSize()
Model
public org.nd4j.linalg.api.ndarray.INDArray activate()
Layer
public org.nd4j.linalg.api.ndarray.INDArray activate(org.nd4j.linalg.api.ndarray.INDArray input)
Layer
public org.nd4j.linalg.api.ndarray.INDArray activationMean()
Layer
activationMean
in interface Layer
public NeuralNetConfiguration conf()
Model
public void clear()
Model
protected void applyDropOutIfNecessary(org.nd4j.linalg.api.ndarray.INDArray input)
public void merge(Layer l, int batchSize)
public Layer.Type type()
Layer
public int numParams()
public void fit(org.nd4j.linalg.api.ndarray.INDArray input)
Model
public Pair<Gradient,Double> gradientAndScore()
Model
gradientAndScore
in interface Model
public double score()
Model
public org.nd4j.linalg.api.ndarray.INDArray input()
Model
public void validateInput()
Model
validateInput
in interface Model
protected Gradient createGradient(org.nd4j.linalg.api.ndarray.INDArray... gradients)
gradients
- the gradients to create frompublic Layer transpose()
Layer
public Pair<Gradient,Gradient> backWard(Gradient ixes, Gradient deltas, org.nd4j.linalg.api.ndarray.INDArray activation, String previousActivation)
Layer
public void accumulateScore(double accum)
Model
accumulateScore
in interface Model
accum
- the amount to accumCopyright © 2015. All Rights Reserved.