Class KerasModel
- java.lang.Object
-
- org.deeplearning4j.nn.modelimport.keras.KerasModel
-
- Direct Known Subclasses:
KerasSequentialModel
public class KerasModel extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected String
className
protected static KerasModelConfiguration
config
protected KerasLayer.DimOrder
dimOrder
protected boolean
enforceTrainingConfig
protected ArrayList<String>
inputLayerNames
protected String
kerasBackend
protected int
kerasMajorVersion
protected Map<String,KerasLayer>
layers
protected List<KerasLayer>
layersOrdered
protected KerasModelBuilder
modelBuilder
protected IUpdater
optimizer
protected ArrayList<String>
outputLayerNames
protected Map<String,InputType>
outputTypes
protected int
truncatedBPTT
protected boolean
useTruncatedBPTT
-
Constructor Summary
Constructors Modifier Constructor Description KerasModel()
protected
KerasModel(String modelJson, String modelYaml, Hdf5Archive weightsArchive, String weightsRoot, String trainingJson, Hdf5Archive trainingArchive, boolean enforceTrainingConfig, int[] inputShape, KerasLayer.DimOrder dimOrder)
(Not recommended) Constructor for (Functional API) Model from model configuration (JSON or YAML), training configuration (JSON), weights, and "training mode" boolean indicator.KerasModel(KerasModelBuilder modelBuilder)
(Recommended) Builder-pattern constructor for (Functional API) Model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ComputationGraph
getComputationGraph()
Build a ComputationGraph from this Keras Model configuration and import weights.ComputationGraph
getComputationGraph(boolean importWeights)
Build a ComputationGraph from this Keras Model configuration and (optionally) import weights.ComputationGraphConfiguration
getComputationGraphConfiguration()
Configure a ComputationGraph from this Keras Model configuration.KerasModelBuilder
modelBuilder()
-
-
-
Field Detail
-
config
protected static KerasModelConfiguration config
-
modelBuilder
protected KerasModelBuilder modelBuilder
-
className
protected String className
-
enforceTrainingConfig
protected boolean enforceTrainingConfig
-
layers
protected Map<String,KerasLayer> layers
-
layersOrdered
protected List<KerasLayer> layersOrdered
-
useTruncatedBPTT
protected boolean useTruncatedBPTT
-
truncatedBPTT
protected int truncatedBPTT
-
kerasMajorVersion
protected int kerasMajorVersion
-
kerasBackend
protected String kerasBackend
-
dimOrder
protected KerasLayer.DimOrder dimOrder
-
optimizer
protected IUpdater optimizer
-
-
Constructor Detail
-
KerasModel
public KerasModel()
-
KerasModel
public KerasModel(KerasModelBuilder modelBuilder) throws UnsupportedKerasConfigurationException, IOException, InvalidKerasConfigurationException
(Recommended) Builder-pattern constructor for (Functional API) Model.- Parameters:
modelBuilder
- builder object- Throws:
IOException
- IO exceptionInvalidKerasConfigurationException
- Invalid Keras configUnsupportedKerasConfigurationException
- Unsupported Keras config
-
KerasModel
protected KerasModel(String modelJson, String modelYaml, Hdf5Archive weightsArchive, String weightsRoot, String trainingJson, Hdf5Archive trainingArchive, boolean enforceTrainingConfig, int[] inputShape, KerasLayer.DimOrder dimOrder) throws IOException, InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
(Not recommended) Constructor for (Functional API) Model from model configuration (JSON or YAML), training configuration (JSON), weights, and "training mode" boolean indicator. When built in training mode, certain unsupported configurations (e.g., unknown regularizers) will throw Exceptions. When enforceTrainingConfig=false, these will generate warnings but will be otherwise ignored.- Parameters:
modelJson
- model configuration JSON stringmodelYaml
- model configuration YAML stringenforceTrainingConfig
- whether to enforce training-related configurations- Throws:
IOException
- IO exceptionInvalidKerasConfigurationException
- Invalid Keras configUnsupportedKerasConfigurationException
- Unsupported Keras config
-
-
Method Detail
-
modelBuilder
public KerasModelBuilder modelBuilder()
-
getComputationGraphConfiguration
public ComputationGraphConfiguration getComputationGraphConfiguration() throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
Configure a ComputationGraph from this Keras Model configuration.- Returns:
- ComputationGraph
- Throws:
InvalidKerasConfigurationException
UnsupportedKerasConfigurationException
-
getComputationGraph
public ComputationGraph getComputationGraph() throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
Build a ComputationGraph from this Keras Model configuration and import weights.- Returns:
- ComputationGraph
- Throws:
InvalidKerasConfigurationException
UnsupportedKerasConfigurationException
-
getComputationGraph
public ComputationGraph getComputationGraph(boolean importWeights) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
Build a ComputationGraph from this Keras Model configuration and (optionally) import weights.- Parameters:
importWeights
- whether to import weights- Returns:
- ComputationGraph
- Throws:
InvalidKerasConfigurationException
UnsupportedKerasConfigurationException
-
-