Input/output functions¶
These functions help writing to and reading from files
-
dynn.io.
load
(filename, ignore_invalid_names=False)¶ Load a ParameterCollection from a
.npz
file.This will recover the subcollection structure.
Parameters: Returns: Loaded ParameterCollection
Return type:
-
dynn.io.
loadtxt
(filename, encoding='utf-8')¶ Read text from a file
-
dynn.io.
populate
(pc, filename, ignore_shape_mismatch=False)¶ Populate a ParameterCollection from a
.npz
fileParameters: - pc (
dynet.ParameterCollection
) – Parameter collection to populate. - filename (str) – File to populate from.
- ignore_shape_mismatch (bool, optional) – Silently ignore shape mismatch
between the parameter and the value in the
.npz
file (just don’t load the parameter and move on)
- pc (
-
dynn.io.
save
(pc, filename, compressed=True)¶ Save a ParameterCollection as a .npz archive.
Each parameter is an entry in the archive and its name describes the subcollection it lives in.
Parameters: - pc (
dynet.ParameterCollection
) – Parameter collection to save. - filename (str) – Target filename. The
.npz
extension will be appended to the file name if it is not already there. - compressed (bool, optional) – Compressed
.npz
(slower but smaller on disk)
- pc (
-
dynn.io.
savetxt
(filename, txt, encoding='utf-8')¶ Save text to a file