deepmd.dpmodel.fitting.general_fitting#

Classes#

GeneralFitting

General fitting class.

Module Contents#

class deepmd.dpmodel.fitting.general_fitting.GeneralFitting(var_name: str, ntypes: int, dim_descrpt: int, neuron: list[int] = [120, 120, 120], resnet_dt: bool = True, numb_fparam: int = 0, numb_aparam: int = 0, bias_atom_e: numpy.ndarray | None = None, rcond: float | None = None, tot_ener_zero: bool = False, trainable: list[bool] | None = None, activation_function: str = 'tanh', precision: str = DEFAULT_PRECISION, layer_name: list[str | None] | None = None, use_aparam_as_mask: bool = False, spin: Any = None, mixed_types: bool = True, exclude_types: list[int] = [], remove_vaccum_contribution: list[bool] | None = None, type_map: list[str] | None = None, seed: int | list[int] | None = None)[source]#

Bases: deepmd.dpmodel.NativeOP, deepmd.dpmodel.fitting.base_fitting.BaseFitting

General fitting class.

Parameters:
var_name

The name of the output variable.

ntypes

The number of atom types.

dim_descrpt

The dimension of the input descriptor.

neuron

Number of neurons \(N\) in each hidden layer of the fitting net

bias_atom_e

Average energy per atom for each element.

resnet_dt

Time-step dt in the resnet construction: \(y = x + dt * \phi (Wx + b)\)

numb_fparam

Number of frame parameter

numb_aparam

Number of atomic parameter

rcond

The condition number for the regression of atomic energy.

tot_ener_zero

Force the total energy to zero. Useful for the charge fitting.

trainable

If the weights of fitting net are trainable. Suppose that we have \(N_l\) hidden layers in the fitting net, this list is of length \(N_l + 1\), specifying if the hidden layers and the output layer are trainable.

activation_function

The activation function \(\boldsymbol{\phi}\) in the embedding net. Supported options are “gelu_tf”, “relu6”, “relu”, “linear”, “gelu”, “none”, “softplus”, “tanh”, “sigmoid”.

precision

The precision of the embedding net parameters. Supported options are “default”, “float16”, “float32”, “float64”.

layer_namelist[Optional[str]], optional

The name of the each layer. If two layers, either in the same fitting or different fittings, have the same name, they will share the same neural network parameters.

use_aparam_as_mask: bool, optional

If True, the atomic parameters will be used as a mask that determines the atom is real/virtual. And the aparam will not be used as the atomic parameters for embedding.

mixed_types

If true, use a uniform fitting net for all atom types, otherwise use different fitting nets for different atom types.

exclude_types: list[int]

Atomic contributions of the excluded atom types are set zero.

remove_vaccum_contribution: list[bool], optional

Remove vacuum contribution before the bias is added. The list assigned each type. For mixed_types provide [True], otherwise it should be a list of the same length as ntypes signaling if or not removing the vacuum contribution for the atom types in the list.

type_map: list[str], Optional

A list of strings. Give the name to each type of atoms.

seed: Optional[Union[int, list[int]]]

Random seed for initializing the network parameters.

var_name[source]#
ntypes[source]#
dim_descrpt[source]#
neuron = [120, 120, 120][source]#
resnet_dt = True[source]#
numb_fparam = 0[source]#
numb_aparam = 0[source]#
rcond = None[source]#
tot_ener_zero = False[source]#
trainable = None[source]#
type_map = None[source]#
activation_function = 'tanh'[source]#
precision = 'float64'[source]#
prec[source]#
layer_name = None[source]#
use_aparam_as_mask = False[source]#
spin = None[source]#
mixed_types = True[source]#
remove_vaccum_contribution = None[source]#
nets[source]#
abstractmethod _net_out_dim()[source]#

Set the FittingNet output dim.

get_dim_fparam() int[source]#

Get the number (dimension) of frame parameters of this atomic model.

get_dim_aparam() int[source]#

Get the number (dimension) of atomic parameters of this atomic model.

get_sel_type() list[int][source]#

Get the selected atom types of this model.

Only atoms with selected atom types have atomic contribution to the result of the model. If returning an empty list, all atom types are selected.

get_type_map() list[str][source]#

Get the name to each type of atoms.

change_type_map(type_map: list[str], model_with_new_type_stat=None) None[source]#

Change the type related params to new ones, according to type_map and the original one in the model. If there are new types in type_map, statistics will be updated accordingly to model_with_new_type_stat for these new types.

__setitem__(key, value) None[source]#
__getitem__(key)[source]#
reinit_exclude(exclude_types: list[int] = []) None[source]#
serialize() dict[source]#

Serialize the fitting to dict.

classmethod deserialize(data: dict) GeneralFitting[source]#

Deserialize the fitting.

Parameters:
datadict

The serialized data

Returns:
BF

The deserialized fitting

_call_common(descriptor: numpy.ndarray, atype: numpy.ndarray, gr: numpy.ndarray | None = None, g2: numpy.ndarray | None = None, h2: numpy.ndarray | None = None, fparam: numpy.ndarray | None = None, aparam: numpy.ndarray | None = None) dict[str, numpy.ndarray][source]#

Calculate the fitting.

Parameters:
descriptor

input descriptor. shape: nf x nloc x nd

atype

the atom type. shape: nf x nloc

gr

The rotationally equivariant and permutationally invariant single particle representation. shape: nf x nloc x ng x 3

g2

The rotationally invariant pair-partical representation. shape: nf x nloc x nnei x ng

h2

The rotationally equivariant pair-partical representation. shape: nf x nloc x nnei x 3

fparam

The frame parameter. shape: nf x nfp. nfp being numb_fparam

aparam

The atomic parameter. shape: nf x nloc x nap. nap being numb_aparam