deepmd.dpmodel.utils.serialization#

Attributes#

Classes#

Counter

A callable counter.

Functions#

traverse_model_dict(model_obj, callback[, is_variable])

Traverse a model dict and call callback on each variable.

save_dp_model(→ None)

Save a DP model to a file in the native format.

load_dp_model(→ dict)

Load a DP model from a file in the native format.

Module Contents#

deepmd.dpmodel.utils.serialization.__version__ = 'unknown'[source]#
deepmd.dpmodel.utils.serialization.traverse_model_dict(model_obj, callback: Callable, is_variable: bool = False)[source]#

Traverse a model dict and call callback on each variable.

Parameters:
model_objobject

The model object to traverse.

callbackcallable()

The callback function to call on each variable.

is_variablebool, optional

Whether the current node is a variable.

Returns:
object

The model object after traversing.

class deepmd.dpmodel.utils.serialization.Counter[source]#

A callable counter.

Examples

>>> counter = Counter()
>>> counter()
0
>>> counter()
1
count = -1[source]#
__call__()[source]#
deepmd.dpmodel.utils.serialization.save_dp_model(filename: str, model_dict: dict) None[source]#

Save a DP model to a file in the native format.

Parameters:
filenamestr

The filename to save to.

model_dictdict

The model dict to save.

deepmd.dpmodel.utils.serialization.load_dp_model(filename: str) dict[source]#

Load a DP model from a file in the native format.

Parameters:
filenamestr

The filename to load from.

Returns:
dict

The loaded model dict, including meta information.