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 StringclassNameprotected static KerasModelConfigurationconfigprotected KerasLayer.DimOrderdimOrderprotected booleanenforceTrainingConfigprotected ArrayList<String>inputLayerNamesprotected StringkerasBackendprotected intkerasMajorVersionprotected Map<String,KerasLayer>layersprotected List<KerasLayer>layersOrderedprotected KerasModelBuildermodelBuilderprotected IUpdateroptimizerprotected ArrayList<String>outputLayerNamesprotected Map<String,InputType>outputTypesprotected inttruncatedBPTTprotected booleanuseTruncatedBPTT
-
Constructor Summary
Constructors Modifier Constructor Description KerasModel()protectedKerasModel(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 ComputationGraphgetComputationGraph()Build a ComputationGraph from this Keras Model configuration and import weights.ComputationGraphgetComputationGraph(boolean importWeights)Build a ComputationGraph from this Keras Model configuration and (optionally) import weights.ComputationGraphConfigurationgetComputationGraphConfiguration()Configure a ComputationGraph from this Keras Model configuration.KerasModelBuildermodelBuilder()
-
-
-
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:
InvalidKerasConfigurationExceptionUnsupportedKerasConfigurationException
-
getComputationGraph
public ComputationGraph getComputationGraph() throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
Build a ComputationGraph from this Keras Model configuration and import weights.- Returns:
- ComputationGraph
- Throws:
InvalidKerasConfigurationExceptionUnsupportedKerasConfigurationException
-
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:
InvalidKerasConfigurationExceptionUnsupportedKerasConfigurationException
-
-