Class Hdf5Archive
- java.lang.Object
-
- org.deeplearning4j.nn.modelimport.keras.Hdf5Archive
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class Hdf5Archive extends Object implements Closeable
-
-
Field Summary
Fields Modifier and Type Field Description static Object
LOCK_OBJECT
HDF5 library is not thread safe - possible to crash if multiple reads etc are performed concurrently in multiple threads.static int
MAX_BUFFER_SIZE_BYTES
-
Constructor Summary
Constructors Constructor Description Hdf5Archive(String archiveFilename)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
closeGroups(org.bytedeco.hdf5.Group[] groupArray)
List<String>
getDataSets(String... groups)
Get list of data sets from group path.List<String>
getGroups(String... groups)
Get list of groups from group path.boolean
hasAttribute(String attributeName, String... groups)
Check whether group path contains string attribute.org.bytedeco.hdf5.Group[]
openGroups(String... groups)
String
readAttributeAsFixedLengthString(String attributeName, int bufferSize)
Read string attribute from group path.String
readAttributeAsJson(String attributeName, String... groups)
Read JSON-formatted string attribute from group path.String
readAttributeAsString(String attributeName, String... groups)
Read string attribute from group path.INDArray
readDataSet(String datasetName, String... groups)
Read data set as ND4J array from group path.
-
-
-
Field Detail
-
MAX_BUFFER_SIZE_BYTES
public static final int MAX_BUFFER_SIZE_BYTES
-
LOCK_OBJECT
public static final Object LOCK_OBJECT
HDF5 library is not thread safe - possible to crash if multiple reads etc are performed concurrently in multiple threads. This object is used for locking read etc activity using synchronized blocks
-
-
Constructor Detail
-
Hdf5Archive
public Hdf5Archive(String archiveFilename)
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
openGroups
public org.bytedeco.hdf5.Group[] openGroups(String... groups)
-
closeGroups
public void closeGroups(org.bytedeco.hdf5.Group[] groupArray)
-
readDataSet
public INDArray readDataSet(String datasetName, String... groups) throws UnsupportedKerasConfigurationException
Read data set as ND4J array from group path.- Parameters:
datasetName
- Name of data setgroups
- Array of zero or more ancestor groups from root to parent.- Returns:
- INDArray of HDF5 group data
- Throws:
UnsupportedKerasConfigurationException
- Unsupported Keras config
-
readAttributeAsJson
public String readAttributeAsJson(String attributeName, String... groups) throws UnsupportedKerasConfigurationException
Read JSON-formatted string attribute from group path.- Parameters:
attributeName
- Name of attributegroups
- Array of zero or more ancestor groups from root to parent.- Returns:
- HDF5 attribute as JSON
- Throws:
UnsupportedKerasConfigurationException
- Unsupported Keras config
-
readAttributeAsString
public String readAttributeAsString(String attributeName, String... groups) throws UnsupportedKerasConfigurationException
Read string attribute from group path.- Parameters:
attributeName
- Name of attributegroups
- Array of zero or more ancestor groups from root to parent.- Returns:
- HDF5 attribute as String
- Throws:
UnsupportedKerasConfigurationException
- Unsupported Keras config
-
hasAttribute
public boolean hasAttribute(String attributeName, String... groups)
Check whether group path contains string attribute.- Parameters:
attributeName
- Name of attributegroups
- Array of zero or more ancestor groups from root to parent.- Returns:
- Boolean indicating whether attribute exists in group path.
-
getDataSets
public List<String> getDataSets(String... groups)
Get list of data sets from group path.- Parameters:
groups
- Array of zero or more ancestor groups from root to parent.- Returns:
- List of HDF5 data set names
-
getGroups
public List<String> getGroups(String... groups)
Get list of groups from group path.- Parameters:
groups
- Array of zero or more ancestor groups from root to parent.- Returns:
- List of HDF5 groups
-
readAttributeAsFixedLengthString
public String readAttributeAsFixedLengthString(String attributeName, int bufferSize) throws UnsupportedKerasConfigurationException
Read string attribute from group path.- Parameters:
attributeName
- Name of attributebufferSize
- buffer size to read- Returns:
- Fixed-length string read from HDF5 attribute name
- Throws:
UnsupportedKerasConfigurationException
- Unsupported Keras config
-
-