Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
35b9aba
Initial plan
Copilot Sep 5, 2025
06a69f5
feat(tf): complete out_bias and out_std implementation with integrati…
Copilot Sep 5, 2025
93cd873
feat(tf): implement decoupled out_bias and out_std in TensorFlow back…
Copilot Sep 6, 2025
0953edf
refactor(tf): consolidate out_bias/out_std application into shared me…
Copilot Sep 6, 2025
4a82cfe
refactor(tf): address review feedback - clean up hasattr checks and b…
Copilot Sep 6, 2025
d8bbd00
refactor(tf): use _get_dim_out() method consistently to eliminate dup…
Copilot Sep 6, 2025
8014159
refactor(tf): consolidate duplicate output dimension logic and remove…
Copilot Sep 6, 2025
519b7bb
chore: remove test system files that should not be committed
Copilot Sep 6, 2025
6d67e25
enable consistent tests
njzjz Sep 7, 2025
11575e8
Apply suggestions from code review
njzjz Sep 7, 2025
10b012e
Potential fix for code scanning alert no. 9973: Unused local variable
njzjz Sep 7, 2025
a061950
Remove unused variable 'nframes' from TensorModel and TestOutBiasStd
njzjz Sep 7, 2025
ab4f31b
Addressing PR comments
Copilot Sep 7, 2025
fc56cab
refactor(tf): remove get/set methods for out_bias and out_std and upd…
Copilot Sep 7, 2025
012e556
fix tests
njzjz Sep 7, 2025
9a04df9
fix(tf): add missing _apply_out_bias_std call in TensorModel build me…
Copilot Sep 7, 2025
ba1204e
Revert "fix(tf): add missing _apply_out_bias_std call in TensorModel …
njzjz Sep 8, 2025
552acd2
fix dos
njzjz Sep 8, 2025
000a453
fix nall/nloc issues
njzjz Sep 8, 2025
aa90139
feat(tf): add r_differentiable and c_differentiable to polar fitting …
Copilot Sep 8, 2025
a1cd310
fix(tf): remove r_differentiable and c_differentiable from polar fitt…
Copilot Sep 8, 2025
0281aa8
chore: remove system directory test files and add to .gitignore
Copilot Sep 8, 2025
059fd74
feat(tf): add debug logging for out_bias/out_std fallback behavior
Copilot Sep 10, 2025
600caab
style: update logging to follow codebase pattern and remove unnecessa…
Copilot Sep 10, 2025
35b89cf
refactor(tf): remove unused _get_selected_atype method from TensorModel
Copilot Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ lcurve.out
out.json
input_v2_compat.json
frozen_model.*

# Test system directories
system/
10 changes: 9 additions & 1 deletion deepmd/tf/fit/dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ def serialize(self, suffix: str) -> dict:
"dim_descrpt": self.dim_descrpt,
"embedding_width": self.dim_rot_mat_1,
"mixed_types": self.mixed_types,
"dim_out": 3,
"neuron": self.n_neuron,
"resnet_dt": self.resnet_dt,
"numb_fparam": self.numb_fparam,
Expand Down Expand Up @@ -458,6 +457,15 @@ def serialize(self, suffix: str) -> dict:
),
},
"type_map": self.type_map,
"var_name": "dipole",
"rcond": None,
"tot_ener_zero": False,
"trainable": self.trainable,
"layer_name": None,
"use_aparam_as_mask": False,
"spin": None,
"r_differentiable": True,
"c_differentiable": True,
}
return data

Expand Down
5 changes: 5 additions & 0 deletions deepmd/tf/fit/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ def serialize(self, suffix: str = "") -> dict:
"case_embd": None,
},
"type_map": self.type_map,
"tot_ener_zero": False,
"layer_name": None,
"use_aparam_as_mask": False,
"spin": None,
"atom_ener": None,
}
return data

Expand Down
15 changes: 13 additions & 2 deletions deepmd/tf/fit/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import numpy as np

from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.tf.common import (
cast_precision,
get_activation_func,
Expand Down Expand Up @@ -641,7 +644,6 @@ def serialize(self, suffix: str) -> dict:
"dim_descrpt": self.dim_descrpt,
"embedding_width": self.dim_rot_mat_1,
"mixed_types": self.mixed_types,
"dim_out": 3,
"neuron": self.n_neuron,
"resnet_dt": self.resnet_dt,
"numb_fparam": self.numb_fparam,
Expand All @@ -652,7 +654,6 @@ def serialize(self, suffix: str) -> dict:
"precision": self.fitting_precision.name,
"exclude_types": [],
"fit_diag": self.fit_diag,
"scale": list(self.scale),
"shift_diag": self.shift_diag,
"nets": self.serialize_network(
ntypes=self.ntypes,
Expand All @@ -674,8 +675,18 @@ def serialize(self, suffix: str) -> dict:
"case_embd": None,
"scale": self.scale.reshape(-1, 1),
"constant_matrix": self.constant_matrix.reshape(-1),
"bias_atom_e": np.zeros(
(self.ntypes, self.dim_rot_mat_1), dtype=GLOBAL_NP_FLOAT_PRECISION
),
},
"type_map": self.type_map,
"var_name": "polar",
"rcond": None,
"tot_ener_zero": False,
"trainable": self.trainable,
"layer_name": None,
"use_aparam_as_mask": False,
"spin": None,
}
return data

Expand Down
7 changes: 7 additions & 0 deletions deepmd/tf/model/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def build(
t_ver = tf.constant(MODEL_VERSION, name="model_version", dtype=tf.string)
t_od = tf.constant(self.numb_dos, name="output_dim", dtype=tf.int32)

# Initialize out_bias and out_std for DOS models
self.init_out_stat(suffix=suffix)

coord = tf.reshape(coord_, [-1, natoms[1] * 3])
atype = tf.reshape(atype_, [-1, natoms[1]])
input_dict["nframes"] = tf.shape(coord)[0]
Expand Down Expand Up @@ -181,6 +184,10 @@ def build(
atom_dos = self.fitting.build(
dout, natoms, input_dict, reuse=reuse, suffix=suffix
)

# Apply out_bias and out_std directly to DOS output
atom_dos = self._apply_out_bias_std(atom_dos, atype, natoms, coord)

self.atom_dos = atom_dos

dos_raw = atom_dos
Expand Down
7 changes: 7 additions & 0 deletions deepmd/tf/model/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def build(
t_mt = tf.constant(self.model_type, name="model_type", dtype=tf.string)
t_ver = tf.constant(MODEL_VERSION, name="model_version", dtype=tf.string)

# Initialize out_bias and out_std for energy models
self.init_out_stat(suffix=suffix)

if self.srtab is not None:
tab_info, tab_data = self.srtab.get()
self.tab_info = tf.get_variable(
Expand Down Expand Up @@ -253,6 +256,10 @@ def build(
atom_ener = self.fitting.build(
dout, natoms, input_dict, reuse=reuse, suffix=suffix
)

# Apply out_bias and out_std directly to atom energy
atom_ener = self._apply_out_bias_std(atom_ener, atype, natoms, coord)

self.atom_ener = atom_ener

if self.srtab is not None:
Expand Down
Loading
Loading