deepmd.nvnmd.utils package
- class deepmd.nvnmd.utils.Encode[source]
Bases:
object
Encoding value as hex, bin, and dec format
Methods
bin2hex
(data)Convert binary string list to hex string list
bin2hex_str
(sbin)Convert binary string to hex string
check_dec
(idec, nbit[, signed, name])Check whether the data (idec) is in the range range is \([0, 2^nbit-1]\) for unsigned range is \([-2^{nbit-1}, 2^{nbit-1}-1]\) for signed
dec2bin
(idec[, nbit, signed, name])Convert dec array to binary string list
extend_bin
(slbin, nfull)Extend the element of list (slbin) to the length (nfull)
extend_hex
(slhex, nfull)Extend the element of list (slhex) to the length (nfull)
extend_list
(slbin, nfull)Extend the list (slbin) to the length (nfull) the attched element of list is 0
hex2bin
(data)Convert hex string list to binary string list
hex2bin_str
(shex)Convert hex string to binary string
merge_bin
(slbin, nmerge)Merge binary string list per nmerge value
qc
(v[, nbit])Quantize value using ceil
qf
(v[, nbit])Quantize value using floor
qr
(v[, nbit])Quantize value using round
reverse_bin
(slbin, nreverse)Reverse binary string list per nreverse value
split_bin
(sbin, nbit)Split sbin into many segment with the length nbit
- check_dec(idec, nbit, signed=False, name='')[source]
Check whether the data (idec) is in the range range is \([0, 2^nbit-1]\) for unsigned range is \([-2^{nbit-1}, 2^{nbit-1}-1]\) for signed
- extend_bin(slbin, nfull)[source]
Extend the element of list (slbin) to the length (nfull)
such as, when
slbin = [‘10010’,’10100’],nfull = 6extent to
[‘010010’,’010100’]
- class deepmd.nvnmd.utils.FioBin[source]
Bases:
object
Input and output for binary file
Methods
load
([file_name, default_value])Load binary file into bytes value
save
([file_name, data])Save hex string into binary file
- class deepmd.nvnmd.utils.FioDic[source]
Bases:
object
Input and output for dict class data the file can be .json or .npy file containing a dictionary
Methods
update
(jdata, jdata_o)Update key-value pair is key in jdata_o.keys()
get
load
save
- class deepmd.nvnmd.utils.FioTxt[source]
Bases:
object
Input and output for .txt file with string
Methods
load
([file_name, default_value])Load .txt file into string list
save
([file_name, data])Save string list into .txt file
- deepmd.nvnmd.utils.get_filter_weight(weights: dict, spe_i: int, spe_j: int, layer_l: int)[source]
Get weight and bias of embedding network
- Parameters
- spe_i(int)
special order of central atom i 0~ntype-1
- spe_j(int)
special order of neighbor atom j 0~ntype-1
- layer_l
layer order in embedding network 1~nlayer
- deepmd.nvnmd.utils.get_fitnet_weight(weights: dict, spe_i: int, layer_l: int, nlayer: int = 10)[source]
Get weight and bias of fitting network
- Parameters
- spe_i(int)
special order of central atom i 0~ntype-1
- layer_l(int)
layer order in embedding network 0~nlayer-1
- deepmd.nvnmd.utils.map_nvnmd(x, map_y, map_dy, prec, nbit=None)[source]
Mapping function implemented by numpy
- deepmd.nvnmd.utils.one_layer(inputs, outputs_size, activation_fn=<function tanh>, precision=tf.float64, stddev=1.0, bavg=0.0, name='linear', reuse=None, seed=None, use_timestep=False, trainable=True, useBN=False, uniform_seed=False, initial_variables=None, mixed_prec=None, final_layer=False)[source]
Build one layer with continuous or quantized value. Its weight and bias can be initialed with random or constant value.
Submodules
deepmd.nvnmd.utils.argcheck module
deepmd.nvnmd.utils.config module
- class deepmd.nvnmd.utils.config.NvnmdConfig(jdata: dict)[source]
Bases:
object
Configuration for NVNMD record the message of model such as size, using nvnmd or not
- Parameters
- jdata
a dictionary of input script
References
DOI: 10.1038/s41524-022-00773-z
Methods
Display the log of NVNMD
Generate input script with member element one by one
Generate model/descriptor in input script
Generate model/fitting_net in input script
Generate learning_rate in input script
Generate loss in input script
Generate model in input script
Generate nvnmd in input script
Generate training in input script
init_ctrl
(jdata[, jdata_parent])Initial members about control signal
init_dscp
(jdata[, jdata_parent])Initial members about descriptor
init_fitn
(jdata[, jdata_parent])Initial members about fitting network
init_from_config
(jdata)Initial member element one by one
init_from_deepmd_input
(jdata)Initial members with input script of deepmd
init_from_jdata
([jdata])Initial this class with jdata loaded from input script
init_nbit
(jdata[, jdata_parent])Initial members about quantification precision
Initial net_size
init_size
(jdata[, jdata_parent])Initial members about ram capacity
init_train_mode
([mod])Configure for taining cnn or qnn
Initial member with dict
save
([file_name])Save all configuration to file
- init_fitn(jdata: dict, jdata_parent: dict = {}) dict [source]
Initial members about fitting network
deepmd.nvnmd.utils.encode module
- class deepmd.nvnmd.utils.encode.Encode[source]
Bases:
object
Encoding value as hex, bin, and dec format
Methods
bin2hex
(data)Convert binary string list to hex string list
bin2hex_str
(sbin)Convert binary string to hex string
check_dec
(idec, nbit[, signed, name])Check whether the data (idec) is in the range range is \([0, 2^nbit-1]\) for unsigned range is \([-2^{nbit-1}, 2^{nbit-1}-1]\) for signed
dec2bin
(idec[, nbit, signed, name])Convert dec array to binary string list
extend_bin
(slbin, nfull)Extend the element of list (slbin) to the length (nfull)
extend_hex
(slhex, nfull)Extend the element of list (slhex) to the length (nfull)
extend_list
(slbin, nfull)Extend the list (slbin) to the length (nfull) the attched element of list is 0
hex2bin
(data)Convert hex string list to binary string list
hex2bin_str
(shex)Convert hex string to binary string
merge_bin
(slbin, nmerge)Merge binary string list per nmerge value
qc
(v[, nbit])Quantize value using ceil
qf
(v[, nbit])Quantize value using floor
qr
(v[, nbit])Quantize value using round
reverse_bin
(slbin, nreverse)Reverse binary string list per nreverse value
split_bin
(sbin, nbit)Split sbin into many segment with the length nbit
- check_dec(idec, nbit, signed=False, name='')[source]
Check whether the data (idec) is in the range range is \([0, 2^nbit-1]\) for unsigned range is \([-2^{nbit-1}, 2^{nbit-1}-1]\) for signed
- extend_bin(slbin, nfull)[source]
Extend the element of list (slbin) to the length (nfull)
such as, when
slbin = [‘10010’,’10100’],nfull = 6extent to
[‘010010’,’010100’]
deepmd.nvnmd.utils.fio module
- class deepmd.nvnmd.utils.fio.Fio[source]
Bases:
object
Basic class for FIO
Methods
create_file_path
exits
get_file_list
is_file
is_path
mkdir
- class deepmd.nvnmd.utils.fio.FioBin[source]
Bases:
object
Input and output for binary file
Methods
load
([file_name, default_value])Load binary file into bytes value
save
([file_name, data])Save hex string into binary file
- class deepmd.nvnmd.utils.fio.FioDic[source]
Bases:
object
Input and output for dict class data the file can be .json or .npy file containing a dictionary
Methods
update
(jdata, jdata_o)Update key-value pair is key in jdata_o.keys()
get
load
save
- class deepmd.nvnmd.utils.fio.FioJsonDic[source]
Bases:
object
Input and output for .json file containing dictionary
Methods
load
([file_name, default_value])Load .json file into dict
save
([file_name, dic])Save dict into .json file
- class deepmd.nvnmd.utils.fio.FioNpyDic[source]
Bases:
object
Input and output for .npy file containing dictionary
Methods
load
save
deepmd.nvnmd.utils.network module
- deepmd.nvnmd.utils.network.matmul2_qq(a, b, nbit)[source]
Quantized matmul operation for 2d tensor. a and b is input tensor, nbit represent quantification precision
- deepmd.nvnmd.utils.network.matmul3_qq(a, b, nbit)[source]
Quantized matmul operation for 3d tensor. a and b is input tensor, nbit represent quantification precision
- deepmd.nvnmd.utils.network.one_layer(inputs, outputs_size, activation_fn=<function tanh>, precision=tf.float64, stddev=1.0, bavg=0.0, name='linear', reuse=None, seed=None, use_timestep=False, trainable=True, useBN=False, uniform_seed=False, initial_variables=None, mixed_prec=None, final_layer=False)[source]
Build one layer with continuous or quantized value. Its weight and bias can be initialed with random or constant value.
- deepmd.nvnmd.utils.network.one_layer_wb(shape, outputs_size, bavg, stddev, precision, trainable, initial_variables, seed, uniform_seed, name)[source]
- deepmd.nvnmd.utils.network.qf(x, nbit)[source]
Quantize and floor tensor x with quantification precision nbit.
- deepmd.nvnmd.utils.network.qr(x, nbit)[source]
Quantize and round tensor x with quantification precision nbit.
deepmd.nvnmd.utils.op module
deepmd.nvnmd.utils.weight module
- deepmd.nvnmd.utils.weight.get_constant_initializer(weights, name)[source]
Get initial value by name and create a initializer
- deepmd.nvnmd.utils.weight.get_filter_weight(weights: dict, spe_i: int, spe_j: int, layer_l: int)[source]
Get weight and bias of embedding network
- Parameters
- spe_i(int)
special order of central atom i 0~ntype-1
- spe_j(int)
special order of neighbor atom j 0~ntype-1
- layer_l
layer order in embedding network 1~nlayer
- deepmd.nvnmd.utils.weight.get_fitnet_weight(weights: dict, spe_i: int, layer_l: int, nlayer: int = 10)[source]
Get weight and bias of fitting network
- Parameters
- spe_i(int)
special order of central atom i 0~ntype-1
- layer_l(int)
layer order in embedding network 0~nlayer-1