public class KerasModelUtils extends Object
| Constructor and Description |
|---|
KerasModelUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Model |
copyWeightsToModel(Model model,
Map<String,KerasLayer> kerasLayers)
Helper function to import weights from nested Map into existing model.
|
static String |
determineKerasBackend(Map<String,Object> modelConfig,
KerasModelConfiguration config)
Determine Keras backend
|
static int |
determineKerasMajorVersion(Map<String,Object> modelConfig,
KerasModelConfiguration config)
Determine Keras major version
|
static void |
importWeights(Hdf5Archive weightsArchive,
String weightsRoot,
Map<String,KerasLayer> layers,
int kerasVersion,
String backend)
Store weights to import with each associated Keras layer.
|
static Map<String,Object> |
parseJsonString(String json)
Convenience function for parsing JSON strings.
|
static Map<String,Object> |
parseModelConfig(String modelJson,
String modelYaml)
Parse Keras model configuration from JSON or YAML string representation
|
static Map<String,Object> |
parseYamlString(String yaml)
Convenience function for parsing YAML strings.
|
public static Model copyWeightsToModel(Model model, Map<String,KerasLayer> kerasLayers) throws InvalidKerasConfigurationException
model - DL4J Model interfaceInvalidKerasConfigurationException - Invalid Keras configpublic static int determineKerasMajorVersion(Map<String,Object> modelConfig, KerasModelConfiguration config) throws InvalidKerasConfigurationException
modelConfig - parsed model configuration for keras modelconfig - basic model configuration (KerasModelConfiguration)InvalidKerasConfigurationException - Invalid Keras configpublic static String determineKerasBackend(Map<String,Object> modelConfig, KerasModelConfiguration config)
modelConfig - parsed model configuration for keras modelconfig - basic model configuration (KerasModelConfiguration)InvalidKerasConfigurationException - Invalid Keras configpublic static void importWeights(Hdf5Archive weightsArchive, String weightsRoot, Map<String,KerasLayer> layers, int kerasVersion, String backend) throws InvalidKerasConfigurationException, UnsupportedKerasConfigurationException
weightsArchive - Hdf5ArchiveweightsRoot - root of weights in HDF5 archiveInvalidKerasConfigurationException - Invalid Keras configurationUnsupportedKerasConfigurationExceptionpublic static Map<String,Object> parseModelConfig(String modelJson, String modelYaml) throws IOException, InvalidKerasConfigurationException
modelJson - JSON string representing model (potentially null)modelYaml - YAML string representing model (potentially null)IOException - IO exceptionInvalidKerasConfigurationException - Invalid Keras configpublic static Map<String,Object> parseJsonString(String json) throws IOException
json - String containing valid JSONIOException - IO exceptionpublic static Map<String,Object> parseYamlString(String yaml) throws IOException
yaml - String containing valid YAMLIOException - IO exceptionCopyright © 2021. All rights reserved.