Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pt): finetuning property/dipole/polar/dos fitting with multi-dimensional data causes error #4145

Open
wants to merge 16 commits into
base: devel
Choose a base branch
from
Open
Changes from 3 commits
Commits
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
20 changes: 20 additions & 0 deletions deepmd/pt/train/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,26 @@ def collect_single_finetune_params(
_new_state_dict[item_key] = (
_random_state_dict[item_key].clone().detach()
)
elif _new_fitting and (
(".out_bias" in item_key) or (".out_std" in item_key)
):
new_key = item_key.replace(
f".{_model_key}.", f".{_model_key_from}."
)
if (
_random_state_dict[item_key].shape[-1]
!= _origin_state_dict[new_key].shape[-1]
):
assert (
_random_state_dict[item_key].shape[:-1]
== _origin_state_dict[new_key].shape[:-1]
)
Chengqian-Zhang marked this conversation as resolved.
Show resolved Hide resolved
_origin_state_dict[new_key] = _origin_state_dict[
new_key
].expand(_random_state_dict[item_key].shape)
_new_state_dict[item_key] = (
_origin_state_dict[new_key].clone().detach()
)
Chengqian-Zhang marked this conversation as resolved.
Show resolved Hide resolved
else:
new_key = item_key.replace(
f".{_model_key}.", f".{_model_key_from}."
Expand Down
Loading