Package org.deeplearning4j.nn.conf
Class ComputationGraphConfiguration
- java.lang.Object
-
- org.deeplearning4j.nn.conf.ComputationGraphConfiguration
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class ComputationGraphConfiguration extends Object implements Serializable, Cloneable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ComputationGraphConfiguration.GraphBuilder
-
Field Summary
Fields Modifier and Type Field Description protected BackpropType
backpropType
protected CacheMode
cacheMode
protected DataType
dataType
protected NeuralNetConfiguration
defaultConfiguration
protected int
epochCount
protected WorkspaceMode
inferenceWorkspaceMode
protected int
iterationCount
protected List<String>
networkInputs
List of inputs to the network, by nameprotected List<String>
networkOutputs
List of network outputs, by nameprotected int
tbpttBackLength
protected int
tbpttFwdLength
protected int[]
topologicalOrder
protected List<String>
topologicalOrderStr
protected WorkspaceMode
trainingWorkspaceMode
protected boolean
validateOutputLayerConfig
protected Map<String,List<String>>
vertexInputs
protected Map<String,GraphVertex>
vertices
-
Constructor Summary
Constructors Constructor Description ComputationGraphConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPreProcessors(boolean addPreprocIfNecessary, boolean forceOverrideInputs, InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network.void
addPreProcessors(boolean forceOverrideInputs, InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network.void
addPreProcessors(InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network.ComputationGraphConfiguration
clone()
static ComputationGraphConfiguration
fromJson(String json)
Create a computation graph configuration from jsonstatic ComputationGraphConfiguration
fromYaml(String json)
Create a neural net configuration from YAMLMap<String,InputType>
getLayerActivationTypes(boolean addPreprocIfNecessary, boolean overrideInputs, InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph.Map<String,InputType>
getLayerActivationTypes(boolean addPreprocIfNecessary, InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph.Map<String,InputType>
getLayerActivationTypes(InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph.NetworkMemoryReport
getMemoryReport(InputType... inputTypes)
Get aMemoryReport
for the given computation graph configuration.String
toJson()
String
toString()
String
toYaml()
void
validate()
Check the configuration, make sure it is validvoid
validate(boolean allowDisconnected, boolean allowNoOutput)
Check the configuration, make sure it is valid
-
-
-
Field Detail
-
vertices
protected Map<String,GraphVertex> vertices
-
trainingWorkspaceMode
protected WorkspaceMode trainingWorkspaceMode
-
inferenceWorkspaceMode
protected WorkspaceMode inferenceWorkspaceMode
-
cacheMode
protected CacheMode cacheMode
-
dataType
protected DataType dataType
-
validateOutputLayerConfig
protected boolean validateOutputLayerConfig
-
backpropType
protected BackpropType backpropType
-
tbpttFwdLength
protected int tbpttFwdLength
-
tbpttBackLength
protected int tbpttBackLength
-
defaultConfiguration
protected NeuralNetConfiguration defaultConfiguration
-
iterationCount
protected int iterationCount
-
epochCount
protected int epochCount
-
topologicalOrder
protected int[] topologicalOrder
-
-
Method Detail
-
toYaml
public String toYaml()
- Returns:
- YAML representation of configuration
-
fromYaml
public static ComputationGraphConfiguration fromYaml(String json)
Create a neural net configuration from YAML- Parameters:
json
- the neural net configuration from YAML- Returns:
ComputationGraphConfiguration
-
toJson
public String toJson()
- Returns:
- JSON representation of computation graph configuration
-
fromJson
public static ComputationGraphConfiguration fromJson(String json)
Create a computation graph configuration from json- Parameters:
json
- the neural net configuration from json- Returns:
ComputationGraphConfiguration
-
clone
public ComputationGraphConfiguration clone()
-
validate
public void validate()
Check the configuration, make sure it is valid- Throws:
IllegalStateException
- if configuration is not valid
-
validate
public void validate(boolean allowDisconnected, boolean allowNoOutput)
Check the configuration, make sure it is valid- Parameters:
allowDisconnected
- If true: don't throw an exception on vertices that are 'disconnected'. A disconnected vertex is one that is not an output, and doesn't connect to any other vertices. i.e., it's output activations don't go anywhere- Throws:
IllegalStateException
- if configuration is not valid
-
addPreProcessors
public void addPreProcessors(InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network. Inputs are specified using theInputType
class, in the same order in which the inputs were defined in the original configuration.
For example, in a network with two inputs: a convolutional input (28x28x1 images) and feed forward inputs, use.addPreProcessors(InputType.convolutional(28,28,1),InputType.feedForward())
.
For the CNN->Dense and CNN->RNN transitions, the nIns on the Dense/RNN layers will also be added automatically. NOTE: This method will be called automatically when using theComputationGraphConfiguration.GraphBuilder.setInputTypes(InputType...)
functionality. See that method for details.
-
addPreProcessors
public void addPreProcessors(boolean addPreprocIfNecessary, boolean forceOverrideInputs, InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network. Inputs are specified using theInputType
class, in the same order in which the inputs were defined in the original configuration.
For example, in a network with two inputs: a convolutional input (28x28x1 images) and feed forward inputs, use.addPreProcessors(InputType.convolutional(28,28,1),InputType.feedForward())
.
For the CNN->Dense and CNN->RNN transitions, the nIns on the Dense/RNN layers will also be added automatically. NOTE: This method will be called automatically when using theComputationGraphConfiguration.GraphBuilder.setInputTypes(InputType...)
functionality. See that method for details.- Parameters:
forceOverrideInputs
- whether to forcibly over ride inputs or not when setting up pre processinginputTypes
- the input types to set
-
addPreProcessors
public void addPreProcessors(boolean forceOverrideInputs, InputType... inputTypes)
Add preprocessors automatically, given the specified types of inputs for the network. Inputs are specified using theInputType
class, in the same order in which the inputs were defined in the original configuration.
For example, in a network with two inputs: a convolutional input (28x28x1 images) and feed forward inputs, use.addPreProcessors(InputType.convolutional(28,28,1),InputType.feedForward())
.
For the CNN->Dense and CNN->RNN transitions, the nIns on the Dense/RNN layers will also be added automatically. NOTE: This method will be called automatically when using theComputationGraphConfiguration.GraphBuilder.setInputTypes(InputType...)
functionality. See that method for details.- Parameters:
forceOverrideInputs
- whether to forcibly over ride inputs or not when setting up pre processinginputTypes
- the input types to set
-
getLayerActivationTypes
public Map<String,InputType> getLayerActivationTypes(InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph. Note that this method will automatically add preprocessors if required, to handle (for example) the transition between CNN and dense layers.- Parameters:
inputTypes
- Input types for the network- Returns:
- A map of activation types for the graph (key: vertex name. value: type of activations out of that vertex)
-
getLayerActivationTypes
public Map<String,InputType> getLayerActivationTypes(boolean addPreprocIfNecessary, boolean overrideInputs, InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph. Note that this method can also add preprocessors if required (to handle transitions between some layer types such as convolutional -> dense, for example)- Parameters:
addPreprocIfNecessary
- If true: add any required preprocessors, in the process of calculating the layer activation sizesoverrideInputs
- whether to forcibly over ride inputs when setting inputsinputTypes
- Input types for the network- Returns:
- A map of activation types for the graph (key: vertex name. value: type of activations out of that vertex)
-
getLayerActivationTypes
public Map<String,InputType> getLayerActivationTypes(boolean addPreprocIfNecessary, InputType... inputTypes)
For the given input shape/type for the network, return a map of activation sizes for each layer and vertex in the graph. Note that this method can also add preprocessors if required (to handle transitions between some layer types such as convolutional -> dense, for example)- Parameters:
addPreprocIfNecessary
- If true: add any required preprocessors, in the process of calculating the layer activation sizesinputTypes
- Input types for the network- Returns:
- A map of activation types for the graph (key: vertex name. value: type of activations out of that vertex)
-
getMemoryReport
public NetworkMemoryReport getMemoryReport(InputType... inputTypes)
Get aMemoryReport
for the given computation graph configuration. This is used to estimate the memory requirements for the given network configuration and input- Parameters:
inputTypes
- Input types for the network- Returns:
- Memory report for the network
-
-