Class LayerVertex
- java.lang.Object
-
- org.deeplearning4j.nn.graph.vertex.BaseGraphVertex
-
- org.deeplearning4j.nn.graph.vertex.impl.LayerVertex
-
- All Implemented Interfaces:
Serializable
,Trainable
,GraphVertex
public class LayerVertex extends BaseGraphVertex
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.deeplearning4j.nn.graph.vertex.BaseGraphVertex
dataType, epsilon, graph, inputs, inputVertices, outputVertex, outputVertices, vertexIndex, vertexName
-
-
Constructor Summary
Constructors Constructor Description LayerVertex(ComputationGraph graph, String name, int vertexIndex, Layer layer, InputPreProcessor layerPreProcessor, boolean outputVertex, DataType dataType)
Create a network input vertex:LayerVertex(ComputationGraph graph, String name, int vertexIndex, VertexIndices[] inputVertices, VertexIndices[] outputVertices, Layer layer, InputPreProcessor layerPreProcessor, boolean outputVertex, DataType dataType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyPreprocessorAndSetInput(LayerWorkspaceMgr workspaceMgr)
boolean
canDoBackward()
Whether the GraphVertex can do backward pass.double
computeScore(double r, boolean training, LayerWorkspaceMgr workspaceMgr)
INDArray
computeScoreForExamples(double r, LayerWorkspaceMgr workspaceMgr)
Pair<Gradient,INDArray[]>
doBackward(boolean tbptt, LayerWorkspaceMgr workspaceMgr)
Do backward passINDArray
doForward(boolean training, LayerWorkspaceMgr workspaceMgr)
Do forward pass using the stored inputsPair<INDArray,MaskState>
feedForwardMaskArrays(INDArray[] maskArrays, MaskState currentMaskState, int minibatchSize)
TrainingConfig
getConfig()
INDArray
getGradientsViewArray()
Layer
getLayer()
Get the Layer (if any).boolean
hasLayer()
Whether the GraphVertex contains aLayer
object or notboolean
isOutputVertex()
Whether the GraphVertex is an output vertexINDArray
params()
Map<String,INDArray>
paramTable(boolean backpropOnly)
Get the parameter table for the vertexvoid
setBackpropGradientsViewArray(INDArray backpropGradientsViewArray)
void
setInput(int inputNumber, INDArray input, LayerWorkspaceMgr workspaceMgr)
Set the input activations.void
setLayerAsFrozen()
Only applies to layer vertices.String
toString()
-
Methods inherited from class org.deeplearning4j.nn.graph.vertex.BaseGraphVertex
canDoForward, clear, clearVertex, getEpsilon, getInputVertices, getNumInputArrays, getNumOutputConnections, getOutputVertices, getVertexIndex, getVertexName, isInputVertex, numParams, setEpsilon, setInputVertices, setOutputVertices, updaterDivideByMinibatch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.deeplearning4j.nn.graph.vertex.GraphVertex
getInputs, setInputs, setOutputVertex
-
-
-
-
Constructor Detail
-
LayerVertex
public LayerVertex(ComputationGraph graph, String name, int vertexIndex, Layer layer, InputPreProcessor layerPreProcessor, boolean outputVertex, DataType dataType)
Create a network input vertex:
-
LayerVertex
public LayerVertex(ComputationGraph graph, String name, int vertexIndex, VertexIndices[] inputVertices, VertexIndices[] outputVertices, Layer layer, InputPreProcessor layerPreProcessor, boolean outputVertex, DataType dataType)
-
-
Method Detail
-
hasLayer
public boolean hasLayer()
Description copied from interface:GraphVertex
Whether the GraphVertex contains aLayer
object or not
-
setLayerAsFrozen
public void setLayerAsFrozen()
Description copied from interface:GraphVertex
Only applies to layer vertices. Will throw exceptions on others. If applied to a layer vertex it will treat the parameters of the layer within it as constant. Activations through these will be calculated as they would as test time regardless of training mode- Specified by:
setLayerAsFrozen
in interfaceGraphVertex
- Overrides:
setLayerAsFrozen
in classBaseGraphVertex
-
paramTable
public Map<String,INDArray> paramTable(boolean backpropOnly)
Description copied from interface:GraphVertex
Get the parameter table for the vertex- Specified by:
paramTable
in interfaceGraphVertex
- Specified by:
paramTable
in interfaceTrainable
- Overrides:
paramTable
in classBaseGraphVertex
- Parameters:
backpropOnly
- If true: exclude unsupervised training parameters- Returns:
- Parameter table
-
isOutputVertex
public boolean isOutputVertex()
Description copied from interface:GraphVertex
Whether the GraphVertex is an output vertex
-
getLayer
public Layer getLayer()
Description copied from interface:GraphVertex
Get the Layer (if any). Returns null ifGraphVertex.hasLayer()
== false
-
doForward
public INDArray doForward(boolean training, LayerWorkspaceMgr workspaceMgr)
Description copied from interface:GraphVertex
Do forward pass using the stored inputs- Parameters:
training
- if true: forward pass at training time. If false: forward pass at test time- Returns:
- The output (for example, activations) of the GraphVertex
-
applyPreprocessorAndSetInput
public void applyPreprocessorAndSetInput(LayerWorkspaceMgr workspaceMgr)
-
doBackward
public Pair<Gradient,INDArray[]> doBackward(boolean tbptt, LayerWorkspaceMgr workspaceMgr)
Description copied from interface:GraphVertex
Do backward pass- Parameters:
tbptt
- If true: do backprop using truncated BPTT- Returns:
- The gradients (may be null), and the errors/epsilons for all inputs to this GraphVertex
-
setInput
public void setInput(int inputNumber, INDArray input, LayerWorkspaceMgr workspaceMgr)
Description copied from interface:GraphVertex
Set the input activations.- Specified by:
setInput
in interfaceGraphVertex
- Overrides:
setInput
in classBaseGraphVertex
- Parameters:
inputNumber
- Must be in range 0 toGraphVertex.getNumInputArrays()
-1input
- The input array
-
setBackpropGradientsViewArray
public void setBackpropGradientsViewArray(INDArray backpropGradientsViewArray)
Description copied from interface:GraphVertex
-
feedForwardMaskArrays
public Pair<INDArray,MaskState> feedForwardMaskArrays(INDArray[] maskArrays, MaskState currentMaskState, int minibatchSize)
-
toString
public String toString()
- Specified by:
toString
in classBaseGraphVertex
-
canDoBackward
public boolean canDoBackward()
Description copied from interface:GraphVertex
Whether the GraphVertex can do backward pass. Typically, this is just whether all errors/epsilons are set- Specified by:
canDoBackward
in interfaceGraphVertex
- Overrides:
canDoBackward
in classBaseGraphVertex
-
computeScore
public double computeScore(double r, boolean training, LayerWorkspaceMgr workspaceMgr)
-
computeScoreForExamples
public INDArray computeScoreForExamples(double r, LayerWorkspaceMgr workspaceMgr)
-
getConfig
public TrainingConfig getConfig()
- Specified by:
getConfig
in interfaceTrainable
- Overrides:
getConfig
in classBaseGraphVertex
- Returns:
- Training configuration
-
params
public INDArray params()
- Specified by:
params
in interfaceTrainable
- Overrides:
params
in classBaseGraphVertex
- Returns:
- 1d parameter vector
-
getGradientsViewArray
public INDArray getGradientsViewArray()
- Specified by:
getGradientsViewArray
in interfaceTrainable
- Overrides:
getGradientsViewArray
in classBaseGraphVertex
- Returns:
- 1D gradients view array
-
-