deepmd.tf.nvnmd.utils

Submodules

Package Contents

Classes

Encode

Encoding value as hex, bin, and dec format.

FioBin

Input and output for binary file.

FioDic

Input and output for dict class data

FioTxt

Input and output for .txt file with string.

Functions

nvnmd_args()

one_layer(inputs, outputs_size[, activation_fn, ...])

Build one layer with continuous or quantized value.

map_nvnmd(x, map_y, map_dy, prec[, nbit])

Mapping function implemented by numpy.

get_filter_weight(weights, spe_j, layer_l)

Get weight and bias of embedding network.

get_fitnet_weight(weights, spe_i, layer_l[, nlayer])

Get weight and bias of fitting network.

Attributes

nvnmd_cfg

deepmd.tf.nvnmd.utils.nvnmd_args()[source]
deepmd.tf.nvnmd.utils.nvnmd_cfg[source]
class deepmd.tf.nvnmd.utils.Encode[source]

Encoding value as hex, bin, and dec format.

qr(v, nbit: int = 14)[source]

Quantize value using round.

qf(v, nbit: int = 14)[source]

Quantize value using floor.

qc(v, nbit: int = 14)[source]

Quantize value using ceil.

split_expo_mant(v, min=-1000)[source]
find_max_expo(v, expo_min=-1000)[source]
norm_expo(v, nbit_frac=20, expo_min=-1000)[source]
flt2bin_one(v, nbit_expo, nbit_frac)[source]
flt2bin(data, nbit_expo, nbit_frac)[source]

Convert float into binary string list.

byte2hex(bs, nbyte)[source]

Convert byte into hex bs: low byte in the first hex: low byte in the right.

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_list(slbin, nfull)[source]

Extend the list (slbin) to the length (nfull) the attched element of list is 0.

such as, when

slbin = [‘10010’,’10100’],
nfull = 4

extent it to

[‘10010’,’10100’,’00000’,’00000]

extend_bin(slbin, nfull)[source]

Extend the element of list (slbin) to the length (nfull).

such as, when

slbin = [‘10010’,’10100’],
nfull = 6

extent to

[‘010010’,’010100’]

extend_hex(slhex, nfull)[source]

Extend the element of list (slhex) to the length (nfull).

split_bin(sbin, nbit: int)[source]

Split sbin into many segment with the length nbit.

reverse_bin(slbin, nreverse)[source]

Reverse binary string list per nreverse value.

merge_bin(slbin, nmerge)[source]

Merge binary string list per nmerge value.

dec2bin(idec, nbit=10, signed=False, name='')[source]

Convert dec array to binary string list.

hex2bin_str(shex)[source]

Convert hex string to binary string.

hex2bin(data)[source]

Convert hex string list to binary string list.

bin2hex_str(sbin)[source]

Convert binary string to hex string.

bin2hex(data)[source]

Convert binary string list to hex string list.

class deepmd.tf.nvnmd.utils.FioBin[source]

Input and output for binary file.

load(file_name='', default_value='')[source]

Load binary file into bytes value.

save(file_name: str, data: List[str])[source]

Save hex string into binary file.

class deepmd.tf.nvnmd.utils.FioDic[source]

Input and output for dict class data the file can be .json or .npy file containing a dictionary.

load(file_name='', default_value={})[source]
save(file_name='', dic={})[source]
get(jdata, key, default_value)[source]
update(jdata, jdata_o)[source]

Update key-value pair is key in jdata_o.keys().

Parameters:
jdata

new jdata

jdata_o

origin jdata

class deepmd.tf.nvnmd.utils.FioTxt[source]

Input and output for .txt file with string.

load(file_name='', default_value=[])[source]

Load .txt file into string list.

save(file_name: str = '', data: list = [])[source]

Save string list into .txt file.

deepmd.tf.nvnmd.utils.one_layer(inputs, outputs_size, activation_fn=tf.nn.tanh, precision=GLOBAL_TF_FLOAT_PRECISION, 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.tf.nvnmd.utils.map_nvnmd(x, map_y, map_dy, prec, nbit=None)[source]

Mapping function implemented by numpy.

deepmd.tf.nvnmd.utils.get_filter_weight(weights: int, spe_j: int, layer_l: int)[source]

Get weight and bias of embedding network.

Parameters:
weightsdict

weights

spe_jint

special order of neighbor atom j 0~ntype-1

layer_l

layer order in embedding network 1~nlayer

deepmd.tf.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:
weightsdict

weights

spe_iint

special order of central atom i 0~ntype-1

layer_lint

layer order in embedding network 0~nlayer-1

nlayerint

number of layers