deepmd_utils.utils package

Submodules

deepmd_utils.utils.argcheck module

class deepmd_utils.utils.argcheck.ArgsPlugin[source]

Bases: object

Methods

get_all_argument([exclude_hybrid])

Get all arguments.

register(name[, alias])

Register a descriptor argument plugin.

get_all_argument(exclude_hybrid: bool = False) List[Argument][source]

Get all arguments.

Parameters
exclude_hybridbool

exclude hybrid descriptor to prevent circular calls

Returns
List[Argument]

all arguments

register(name: str, alias: Optional[List[str]] = None) Callable[[], List[Argument]][source]

Register a descriptor argument plugin.

Parameters
namestr

the name of a descriptor

aliasList[str], optional

the list of aliases of this descriptor

Returns
Callable[[], List[Argument]]

the registered descriptor argument method

Examples

>>> some_plugin = ArgsPlugin()
>>> @some_plugin.register("some_descrpt")
    def descrpt_some_descrpt_args():
        return []
deepmd_utils.utils.argcheck.descrpt_hybrid_args()[source]
deepmd_utils.utils.argcheck.descrpt_local_frame_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_a_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_a_ebd_v2_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_a_mask_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_a_tpe_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_atten_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_atten_common_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_atten_v2_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_r_args()[source]
deepmd_utils.utils.argcheck.descrpt_se_t_args()[source]
deepmd_utils.utils.argcheck.descrpt_variant_type_args(exclude_hybrid: bool = False) Variant[source]
deepmd_utils.utils.argcheck.fitting_dipole()[source]
deepmd_utils.utils.argcheck.fitting_dos()[source]
deepmd_utils.utils.argcheck.fitting_ener()[source]
deepmd_utils.utils.argcheck.fitting_polar()[source]
deepmd_utils.utils.argcheck.fitting_variant_type_args()[source]
deepmd_utils.utils.argcheck.frozen_model_args() Argument[source]
deepmd_utils.utils.argcheck.gen_args(**kwargs) List[Argument][source]
deepmd_utils.utils.argcheck.gen_doc(*, make_anchor=True, make_link=True, **kwargs)[source]
deepmd_utils.utils.argcheck.gen_json(**kwargs)[source]
deepmd_utils.utils.argcheck.learning_rate_args()[source]
deepmd_utils.utils.argcheck.learning_rate_dict_args()[source]
deepmd_utils.utils.argcheck.learning_rate_exp()[source]
deepmd_utils.utils.argcheck.learning_rate_variant_type_args()[source]
deepmd_utils.utils.argcheck.limit_pref(item)[source]
deepmd_utils.utils.argcheck.linear_ener_model_args() Argument[source]
deepmd_utils.utils.argcheck.list_to_doc(xx)[source]
deepmd_utils.utils.argcheck.loss_args()[source]
deepmd_utils.utils.argcheck.loss_dict_args()[source]
deepmd_utils.utils.argcheck.loss_dos()[source]
deepmd_utils.utils.argcheck.loss_ener()[source]
deepmd_utils.utils.argcheck.loss_ener_spin()[source]
deepmd_utils.utils.argcheck.loss_tensor()[source]
deepmd_utils.utils.argcheck.loss_variant_type_args()[source]
deepmd_utils.utils.argcheck.make_index(keys)[source]
deepmd_utils.utils.argcheck.mixed_precision_args()[source]
deepmd_utils.utils.argcheck.model_args(exclude_hybrid=False)[source]
deepmd_utils.utils.argcheck.model_compression()[source]
deepmd_utils.utils.argcheck.model_compression_type_args()[source]
deepmd_utils.utils.argcheck.modifier_dipole_charge()[source]
deepmd_utils.utils.argcheck.modifier_variant_type_args()[source]
deepmd_utils.utils.argcheck.multi_model_args() Argument[source]
deepmd_utils.utils.argcheck.normalize(data)[source]
deepmd_utils.utils.argcheck.normalize_data_dict(data_dict)[source]
deepmd_utils.utils.argcheck.normalize_fitting_net_dict(fitting_net_dict)[source]
deepmd_utils.utils.argcheck.normalize_fitting_weight(fitting_keys, data_keys, fitting_weight=None)[source]
deepmd_utils.utils.argcheck.normalize_learning_rate_dict(fitting_keys, learning_rate_dict)[source]
deepmd_utils.utils.argcheck.normalize_learning_rate_dict_with_single_learning_rate(fitting_keys, learning_rate)[source]
deepmd_utils.utils.argcheck.normalize_loss_dict(fitting_keys, loss_dict)[source]
deepmd_utils.utils.argcheck.normalize_multi_task(data)[source]
deepmd_utils.utils.argcheck.pairtab_model_args() Argument[source]
deepmd_utils.utils.argcheck.pairwise_dprc() Argument[source]
deepmd_utils.utils.argcheck.spin_args()[source]
deepmd_utils.utils.argcheck.standard_model_args() Argument[source]
deepmd_utils.utils.argcheck.start_pref(item, label=None, abbr=None)[source]
deepmd_utils.utils.argcheck.training_args()[source]
deepmd_utils.utils.argcheck.training_data_args()[source]
deepmd_utils.utils.argcheck.type_embedding_args()[source]
deepmd_utils.utils.argcheck.validation_data_args()[source]

deepmd_utils.utils.argcheck_nvnmd module

deepmd_utils.utils.argcheck_nvnmd.nvnmd_args()[source]

deepmd_utils.utils.batch_size module

class deepmd_utils.utils.batch_size.AutoBatchSize(initial_batch_size: int = 1024, factor: float = 2.0)[source]

Bases: ABC

This class allows DeePMD-kit to automatically decide the maximum batch size that will not cause an OOM error.

Parameters
initial_batch_sizeint, default: 1024

initial batch size (number of total atoms) when DP_INFER_BATCH_SIZE is not set

factorfloat, default: 2.

increased factor

Notes

In some CPU environments, the program may be directly killed when OOM. In this case, by default the batch size will not be increased for CPUs. The environment variable DP_INFER_BATCH_SIZE can be set as the batch size.

In other cases, we assume all OOM error will raise OutOfMemoryError.

Attributes
current_batch_sizeint

current batch size (number of total atoms)

maximum_working_batch_sizeint

maximum working batch size

minimal_not_working_batch_sizeint

minimal not working batch size

Methods

execute(callable, start_index, natoms)

Excuate a method with given batch size.

execute_all(callable, total_size, natoms, ...)

Excuate a method with all given data.

is_gpu_available()

Check if GPU is available.

is_oom_error(e)

Check if the exception is an OOM error.

execute(callable: Callable, start_index: int, natoms: int) Tuple[int, tuple][source]

Excuate a method with given batch size.

Parameters
callableCallable

The method should accept the batch size and start_index as parameters, and returns executed batch size and data.

start_indexint

start index

natomsint

natoms

Returns
int

executed batch size * number of atoms

tuple

result from callable, None if failing to execute

Raises
OutOfMemoryError

OOM when batch size is 1

execute_all(callable: Callable, total_size: int, natoms: int, *args, **kwargs) Tuple[ndarray][source]

Excuate a method with all given data.

Parameters
callableCallable

The method should accept *args and **kwargs as input and return the similiar array.

total_sizeint

Total size

natomsint

The number of atoms

*args

Variable length argument list.

**kwargs

If 2D np.ndarray, assume the first axis is batch; otherwise do nothing.

abstract is_gpu_available() bool[source]

Check if GPU is available.

Returns
bool

True if GPU is available

abstract is_oom_error(e: Exception) bool[source]

Check if the exception is an OOM error.

Parameters
eException

Exception

Returns
bool

True if the exception is an OOM error

deepmd_utils.utils.compat module

Module providing compatibility between 0.x.x and 1.x.x input versions.

deepmd_utils.utils.compat.convert_input_v0_v1(jdata: Dict[str, Any], warning: bool = True, dump: Optional[Union[str, Path]] = None) Dict[str, Any][source]

Convert input from v0 format to v1.

Parameters
jdataDict[str, Any]

loaded json/yaml file

warningbool, optional

whether to show deprecation warning, by default True

dumpOptional[Union[str, Path]], optional

whether to dump converted file, by default None

Returns
Dict[str, Any]

converted output

deepmd_utils.utils.compat.convert_input_v1_v2(jdata: Dict[str, Any], warning: bool = True, dump: Optional[Union[str, Path]] = None) Dict[str, Any][source]
deepmd_utils.utils.compat.deprecate_numb_test(jdata: Dict[str, Any], warning: bool = True, dump: Optional[Union[str, Path]] = None) Dict[str, Any][source]

Deprecate numb_test since v2.1. It has taken no effect since v2.0.

See #1243.

Parameters
jdataDict[str, Any]

loaded json/yaml file

warningbool, optional

whether to show deprecation warning, by default True

dumpOptional[Union[str, Path]], optional

whether to dump converted file, by default None

Returns
Dict[str, Any]

converted output

deepmd_utils.utils.compat.remove_decay_rate(jdata: Dict[str, Any])[source]

Convert decay_rate to stop_lr.

Parameters
jdataDict[str, Any]

input data

deepmd_utils.utils.compat.update_deepmd_input(jdata: Dict[str, Any], warning: bool = True, dump: Optional[Union[str, Path]] = None) Dict[str, Any][source]

deepmd_utils.utils.data module

class deepmd_utils.utils.data.DeepmdData(sys_path: str, set_prefix: str = 'set', shuffle_test: bool = True, type_map: Optional[List[str]] = None, optional_type_map: bool = True, modifier=None, trn_all_set: bool = False, sort_atoms: bool = True)[source]

Bases: object

Class for a data system.

It loads data from hard disk, and mantains the data as a data_dict

Parameters
sys_path

Path to the data system

set_prefix

Prefix for the directories of different sets

shuffle_test

If the test data are shuffled

type_map

Gives the name of different atom types

optional_type_map

If the type_map.raw in each system is optional

modifier

Data modifier that has the method modify_data

trn_all_set

Use all sets as training dataset. Otherwise, if the number of sets is more than 1, the last set is left for test.

sort_atomsbool

Sort atoms by atom types. Required to enable when the data is directly feeded to descriptors except mixed types.

Methods

add(key, ndof[, atomic, must, high_prec, ...])

Add a data item that to be loaded.

avg(key)

Return the average value of an item.

check_batch_size(batch_size)

Check if the system can get a batch of data with batch_size frames.

check_test_size(test_size)

Check if the system can get a test dataset with test_size frames.

get_atom_type()

Get atom types.

get_batch(batch_size)

Get a batch of data with batch_size frames.

get_data_dict()

Get the data_dict.

get_natoms()

Get number of atoms.

get_natoms_vec(ntypes)

Get number of atoms and number of atoms in different types.

get_ntypes()

Number of atom types in the system.

get_numb_batch(batch_size, set_idx)

Get the number of batches in a set.

get_numb_set()

Get number of training sets.

get_sys_numb_batch(batch_size)

Get the number of batches in the data system.

get_test([ntests])

Get the test data with ntests frames.

get_type_map()

Get the type map.

reduce(key_out, key_in)

Generate a new item from the reduction of another atom.

reset_get_batch

add(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[List[int]] = None, repeat: int = 1, default: float = 0.0, dtype: Optional[dtype] = None)[source]

Add a data item that to be loaded.

Parameters
key

The key of the item. The corresponding data is stored in sys_path/set.*/key.npy

ndof

The number of dof

atomic

The item is an atomic property. If False, the size of the data should be nframes x ndof If True, the size of data should be nframes x natoms x ndof

must

The data file sys_path/set.*/key.npy must exist. If must is False and the data file does not exist, the data_dict[find_key] is set to 0.0

high_prec

Load the data and store in float64, otherwise in float32

type_sel

Select certain type of atoms

repeat

The data will be repeated repeat times.

defaultfloat, default=0.

default value of data

dtypenp.dtype, optional

the dtype of data, overwrites high_prec if provided

avg(key)[source]

Return the average value of an item.

check_batch_size(batch_size)[source]

Check if the system can get a batch of data with batch_size frames.

check_test_size(test_size)[source]

Check if the system can get a test dataset with test_size frames.

get_atom_type() List[int][source]

Get atom types.

get_batch(batch_size: int) dict[source]

Get a batch of data with batch_size frames. The frames are randomly picked from the data system.

Parameters
batch_size

size of the batch

get_data_dict() dict[source]

Get the data_dict.

get_natoms()[source]

Get number of atoms.

get_natoms_vec(ntypes: int)[source]

Get number of atoms and number of atoms in different types.

Parameters
ntypes

Number of types (may be larger than the actual number of types in the system).

Returns
natoms

natoms[0]: number of local atoms natoms[1]: total number of atoms held by this processor natoms[i]: 2 <= i < Ntypes+2, number of type i atoms

get_ntypes() int[source]

Number of atom types in the system.

get_numb_batch(batch_size: int, set_idx: int) int[source]

Get the number of batches in a set.

get_numb_set() int[source]

Get number of training sets.

get_sys_numb_batch(batch_size: int) int[source]

Get the number of batches in the data system.

get_test(ntests: int = -1) dict[source]

Get the test data with ntests frames.

Parameters
ntests

Size of the test data set. If ntests is -1, all test data will be get.

get_type_map() List[str][source]

Get the type map.

reduce(key_out: str, key_in: str)[source]

Generate a new item from the reduction of another atom.

Parameters
key_out

The name of the reduced item

key_in

The name of the data item to be reduced

reset_get_batch()[source]

deepmd_utils.utils.data_system module

class deepmd_utils.utils.data_system.DeepmdDataSystem(systems: List[str], batch_size: int, test_size: int, rcut: Optional[float] = None, set_prefix: str = 'set', shuffle_test: bool = True, type_map: Optional[List[str]] = None, optional_type_map: bool = True, modifier=None, trn_all_set=False, sys_probs=None, auto_prob_style='prob_sys_size', sort_atoms: bool = True)[source]

Bases: object

Class for manipulating many data systems.

It is implemented with the help of DeepmdData

Attributes
default_mesh

Mesh for each system.

Methods

add(key, ndof[, atomic, must, high_prec, ...])

Add a data item that to be loaded.

add_dict(adict)

Add items to the data system by a dict.

get_batch([sys_idx])

Get a batch of data from the data systems.

get_batch_mixed()

Get a batch of data from the data systems in the mixed way.

get_batch_size()

Get the batch size.

get_batch_standard([sys_idx])

Get a batch of data from the data systems in the standard way.

get_nbatches()

Get the total number of batches.

get_nsystems()

Get the number of data systems.

get_ntypes()

Get the number of types.

get_sys(idx)

Get a certain data system.

get_sys_ntest([sys_idx])

Get number of tests for the currently selected system, or one defined by sys_idx.

get_test([sys_idx, n_test])

Get test data from the the data systems.

get_type_map()

Get the type map.

reduce(key_out, key_in)

Generate a new item from the reduction of another atom.

compute_energy_shift

get_data_dict

print_summary

set_sys_probs

add(key: str, ndof: int, atomic: bool = False, must: bool = False, high_prec: bool = False, type_sel: Optional[List[int]] = None, repeat: int = 1, default: float = 0.0)[source]

Add a data item that to be loaded.

Parameters
key

The key of the item. The corresponding data is stored in sys_path/set.*/key.npy

ndof

The number of dof

atomic

The item is an atomic property. If False, the size of the data should be nframes x ndof If True, the size of data should be nframes x natoms x ndof

must

The data file sys_path/set.*/key.npy must exist. If must is False and the data file does not exist, the data_dict[find_key] is set to 0.0

high_prec

Load the data and store in float64, otherwise in float32

type_sel

Select certain type of atoms

repeat

The data will be repeated repeat times.

default, default=0.

Default value of data

add_dict(adict: dict) None[source]

Add items to the data system by a dict. adict should have items like .. code-block:: python.

adict[key] = {

“ndof”: ndof, “atomic”: atomic, “must”: must, “high_prec”: high_prec, “type_sel”: type_sel, “repeat”: repeat,

}

For the explaination of the keys see add

compute_energy_shift(rcond=None, key='energy')[source]
property default_mesh: List[ndarray]

Mesh for each system.

get_batch(sys_idx: Optional[int] = None) dict[source]

Get a batch of data from the data systems.

Parameters
sys_idxint

The index of system from which the batch is get. If sys_idx is not None, sys_probs and auto_prob_style are ignored If sys_idx is None, automatically determine the system according to sys_probs or auto_prob_style, see the following. This option does not work for mixed systems.

Returns
dict

The batch data

get_batch_mixed() dict[source]

Get a batch of data from the data systems in the mixed way.

Returns
dict

The batch data

get_batch_size() int[source]

Get the batch size.

get_batch_standard(sys_idx: Optional[int] = None) dict[source]

Get a batch of data from the data systems in the standard way.

Parameters
sys_idxint

The index of system from which the batch is get. If sys_idx is not None, sys_probs and auto_prob_style are ignored If sys_idx is None, automatically determine the system according to sys_probs or auto_prob_style, see the following.

Returns
dict

The batch data

get_data_dict(ii: int = 0) dict[source]
get_nbatches() int[source]

Get the total number of batches.

get_nsystems() int[source]

Get the number of data systems.

get_ntypes() int[source]

Get the number of types.

get_sys(idx: int) DeepmdData[source]

Get a certain data system.

get_sys_ntest(sys_idx=None)[source]

Get number of tests for the currently selected system, or one defined by sys_idx.

get_test(sys_idx: Optional[int] = None, n_test: int = -1)[source]

Get test data from the the data systems.

Parameters
sys_idx

The test dat of system with index sys_idx will be returned. If is None, the currently selected system will be returned.

n_test

Number of test data. If set to -1 all test data will be get.

get_type_map() List[str][source]

Get the type map.

print_summary(name)[source]
reduce(key_out, key_in)[source]

Generate a new item from the reduction of another atom.

Parameters
key_out

The name of the reduced item

key_in

The name of the data item to be reduced

set_sys_probs(sys_probs=None, auto_prob_style: str = 'prob_sys_size')[source]
deepmd_utils.utils.data_system.prob_sys_size_ext(keywords, nsystems, nbatch)[source]
deepmd_utils.utils.data_system.process_sys_probs(sys_probs, nbatch)[source]

deepmd_utils.utils.errors module

exception deepmd_utils.utils.errors.OutOfMemoryError[source]

Bases: Exception

This error is caused by out-of-memory (OOM).

deepmd_utils.utils.model_stat module

deepmd_utils.utils.model_stat.make_stat_input(data, nbatches, merge_sys=True)[source]

Pack data for statistics.

Parameters
data

The data

nbatchesint

The number of batches

merge_sysbool (True)

Merge system data

Returns
all_stat:

A dictionary of list of list storing data for stat. if merge_sys == False data can be accessed by

all_stat[key][sys_idx][batch_idx][frame_idx]

else merge_sys == True can be accessed by

all_stat[key][batch_idx][frame_idx]

deepmd_utils.utils.model_stat.merge_sys_stat(all_stat)[source]

deepmd_utils.utils.pair_tab module

class deepmd_utils.utils.pair_tab.PairTab(filename: str)[source]

Bases: object

Pairwise tabulated potential.

Parameters
filename

File name for the short-range tabulated potential. The table is a text data file with (N_t + 1) * N_t / 2 + 1 columes. The first colume is the distance between atoms. The second to the last columes are energies for pairs of certain types. For example we have two atom types, 0 and 1. The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.

Methods

get()

Get the serialized table.

reinit(filename)

Initialize the tabulated interaction.

get() Tuple[array, array][source]

Get the serialized table.

reinit(filename: str) None[source]

Initialize the tabulated interaction.

Parameters
filename

File name for the short-range tabulated potential. The table is a text data file with (N_t + 1) * N_t / 2 + 1 columes. The first colume is the distance between atoms. The second to the last columes are energies for pairs of certain types. For example we have two atom types, 0 and 1. The columes from 2nd to 4th are for 0-0, 0-1 and 1-1 correspondingly.

deepmd_utils.utils.path module

class deepmd_utils.utils.path.DPH5Path(path: str)[source]

Bases: DPPath

The path class to data system (DeepmdData) for HDF5 files.

Parameters
pathstr

path

Notes

OS - HDF5 relationship:

directory - Group file - Dataset

Methods

glob(pattern)

Search path using the glob pattern.

is_dir()

Check if self is directory.

is_file()

Check if self is file.

load_numpy()

Load NumPy array.

load_txt([dtype])

Load NumPy array from text.

rglob(pattern)

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

is_dir() bool[source]

Check if self is directory.

is_file() bool[source]

Check if self is file.

load_numpy() ndarray[source]

Load NumPy array.

Returns
np.ndarray

loaded NumPy array

load_txt(dtype: Optional[dtype] = None, **kwargs) ndarray[source]

Load NumPy array from text.

Returns
np.ndarray

loaded NumPy array

rglob(pattern: str) List[DPPath][source]

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

class deepmd_utils.utils.path.DPOSPath(path: str)[source]

Bases: DPPath

The OS path class to data system (DeepmdData) for real directories.

Parameters
pathstr

path

Methods

glob(pattern)

Search path using the glob pattern.

is_dir()

Check if self is directory.

is_file()

Check if self is file.

load_numpy()

Load NumPy array.

load_txt(**kwargs)

Load NumPy array from text.

rglob(pattern)

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

is_dir() bool[source]

Check if self is directory.

is_file() bool[source]

Check if self is file.

load_numpy() ndarray[source]

Load NumPy array.

Returns
np.ndarray

loaded NumPy array

load_txt(**kwargs) ndarray[source]

Load NumPy array from text.

Returns
np.ndarray

loaded NumPy array

rglob(pattern: str) List[DPPath][source]

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

class deepmd_utils.utils.path.DPPath(path: str)[source]

Bases: ABC

The path class to data system (DeepmdData).

Parameters
pathstr

path

Methods

glob(pattern)

Search path using the glob pattern.

is_dir()

Check if self is directory.

is_file()

Check if self is file.

load_numpy()

Load NumPy array.

load_txt(**kwargs)

Load NumPy array from text.

rglob(pattern)

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

abstract glob(pattern: str) List[DPPath][source]

Search path using the glob pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

abstract is_dir() bool[source]

Check if self is directory.

abstract is_file() bool[source]

Check if self is file.

abstract load_numpy() ndarray[source]

Load NumPy array.

Returns
np.ndarray

loaded NumPy array

abstract load_txt(**kwargs) ndarray[source]

Load NumPy array from text.

Returns
np.ndarray

loaded NumPy array

abstract rglob(pattern: str) List[DPPath][source]

This is like calling DPPath.glob() with **/ added in front of the given relative pattern.

Parameters
patternstr

glob pattern

Returns
List[DPPath]

list of paths

deepmd_utils.utils.plugin module

Base of plugin systems.

class deepmd_utils.utils.plugin.Plugin[source]

Bases: object

A class to register and restore plugins.

Examples

>>> plugin = Plugin()
>>> @plugin.register("xx")
    def xxx():
        pass
>>> print(plugin.plugins['xx'])
Attributes
pluginsDict[str, object]

plugins

Methods

get_plugin(key)

Visit a plugin by key.

register(key)

Register a plugin.

get_plugin(key) object[source]

Visit a plugin by key.

Parameters
keystr

key of the plugin

Returns
object

the plugin

register(key: str) Callable[[object], object][source]

Register a plugin.

Parameters
keystr

key of the plugin

Returns
Callable[[object], object]

decorator

class deepmd_utils.utils.plugin.PluginVariant(*args, **kwargs)[source]

Bases: object

A class to remove type from input arguments.

class deepmd_utils.utils.plugin.VariantABCMeta(name, bases, namespace, **kwargs)[source]

Bases: VariantMeta, ABCMeta

Methods

__call__(*args, **kwargs)

Remove type and keys that starts with underline.

mro(/)

Return a type's method resolution order.

register(subclass)

Register a virtual subclass of an ABC.

class deepmd_utils.utils.plugin.VariantMeta[source]

Bases: object

Methods

__call__(*args, **kwargs)

Remove type and keys that starts with underline.

deepmd_utils.utils.random module

deepmd_utils.utils.random.choice(a: ndarray, p: Optional[ndarray] = None)[source]

Generates a random sample from a given 1-D array.

Parameters
anp.ndarray

A random sample is generated from its elements.

pnp.ndarray

The probabilities associated with each entry in a.

Returns
np.ndarray

arrays with results and their shapes

deepmd_utils.utils.random.random(size=None)[source]

Return random floats in the half-open interval [0.0, 1.0).

Parameters
size

Output shape.

Returns
np.ndarray

Arrays with results and their shapes.

deepmd_utils.utils.random.seed(val: Optional[int] = None)[source]

Seed the generator.

Parameters
valint

Seed.

deepmd_utils.utils.random.shuffle(x: ndarray)[source]

Modify a sequence in-place by shuffling its contents.

Parameters
xnp.ndarray

The array or list to be shuffled.

deepmd_utils.utils.weight_avg module

deepmd_utils.utils.weight_avg.weighted_average(errors: List[Dict[str, Tuple[float, float]]]) Dict[source]

Compute wighted average of prediction errors (MAE or RMSE) for model.

Parameters
errorsList[Dict[str, Tuple[float, float]]]

List: the error of systems Dict: the error of quantities, name given by the key str: the name of the quantity, must starts with ‘mae’ or ‘rmse’ Tuple: (error, weight)

Returns
Dict

weighted averages