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

[BUG] KeyError of atomic_dipole or atom_dipole #3970

Closed
marvcks opened this issue Jul 12, 2024 · 2 comments · Fixed by #3975
Closed

[BUG] KeyError of atomic_dipole or atom_dipole #3970

marvcks opened this issue Jul 12, 2024 · 2 comments · Fixed by #3975
Assignees
Labels
bug reproduced This bug has been reproduced by developers

Comments

@marvcks
Copy link

marvcks commented Jul 12, 2024

Bug summary

File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/loss/tensor.py", line 60, in build
atomic_polar_hat = label_dict["atom_" + self.label_name]
KeyError: 'atom_dipole'

DeePMD-kit Version

v3.0.0b0

Backend and its version

TensorFlow 2.14.0

How did you download the software?

Offline packages

Input Files, Running Commands, Error Log, etc.

Input Files

dipole_input.json get from deepmd-kit/examples/water_tensor/dipole.

{
  "_comment1": " model parameters",
  "model": {
    "type_map": [
      "O",
      "H"
    ],
    "descriptor": {
      "type": "se_e2_a",
      "sel": [
        46,
        92
      ],
      "rcut_smth": 3.80,
      "rcut": 4.00,
      "neuron": [
        25,
        50,
        100
      ],
      "resnet_dt": false,
      "axis_neuron": 6,
      "type_one_side": true,
      "precision": "float64",
      "seed": 1,
      "_comment2": " that's all"
    },
    "fitting_net": {
      "type": "dipole",
      "sel_type": [
        0
      ],
      "neuron": [
        100,
        100,
        100
      ],
      "resnet_dt": true,
      "precision": "float64",
      "seed": 1,
      "_comment3": " that's all"
    },
    "_comment4": " that's all"
  },
  "learning_rate": {
    "type": "exp",
    "start_lr": 0.01,
    "decay_steps": 5000,
    "_comment5": "that's all"
  },
  "loss": {
    "type": "tensor",
    "pref": 1.0,
    "pref_atomic": 1.0,
    "_comment6": " that's all"
  },
  "_comment7": " traing controls",
  "training": {
    "training_data": {
      "systems": [
        "./training_data/atomic_system",
        "./training_data/global_system"
      ],
      "batch_size": "auto",
      "_comment8": "that's all"
    },
    "validation_data": {
      "systems": [
        "./validation_data/atomic_system",
        "./validation_data/global_system"
      ],
      "batch_size": 1,
      "numb_btch": 3,
      "_comment9": "that's all"
    },
    "numb_steps": 2000,
    "seed": 10,
    "disp_file": "lcurve.out",
    "disp_freq": 100,
    "save_freq": 1000,
    "_comment10": "that's all"
  },
  "_comment11": "that's all"
}

Running Commands

dp train dipole_input.json

Error log

Traceback (most recent call last):
  File "/home/xxxx/deepmd-kit/bin/dp", line 10, in <module>
    sys.exit(main())
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/main.py", line 918, in main
    deepmd_main(args)
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/entrypoints/main.py", line 72, in main
    train_dp(**dict_args)
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/entrypoints/train.py", line 186, in train
    _do_work(jdata, run_opt, is_compress)
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/entrypoints/train.py", line 261, in _do_work
    model.build(train_data, stop_batch, origin_type_map=origin_type_map)
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/train/trainer.py", line 244, in build
    self._build_network(data, suffix)
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/train/trainer.py", line 302, in _build_network
    self.l2_l, self.l2_more = self._build_loss()
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/train/trainer.py", line 257, in _build_loss
    l2_l, l2_more = self.loss.build(
  File "/home/xxxx/deepmd-kit/lib/python3.10/site-packages/deepmd/tf/loss/tensor.py", line 60, in build
    atomic_polar_hat = label_dict["atom_" + self.label_name]

The line number above may not be the same as original code, cuz I printed some variables.

Steps to Reproduce

Files in deepmd-kit/examples/water_tensor/dipole.

Further Information, Files, and Links

No response

@marvcks marvcks added the bug label Jul 12, 2024
@njzjz
Copy link
Member

njzjz commented Jul 12, 2024

due to #3662

@njzjz njzjz added the reproduced This bug has been reproduced by developers label Jul 12, 2024
@njzjz njzjz linked a pull request Jul 13, 2024 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Jul 14, 2024
I believe this should fix #3970 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Updated label naming convention from "atomic_" to "atom_" to ensure
consistency in labeling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@njzjz
Copy link
Member

njzjz commented Jul 14, 2024

Fixed in #3975

@njzjz njzjz closed this as completed Jul 14, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Bugfixes for DeePMD-kit Jul 14, 2024
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this issue Sep 18, 2024
I believe this should fix deepmodeling#3970 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Updated label naming convention from "atomic_" to "atom_" to ensure
consistency in labeling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug reproduced This bug has been reproduced by developers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants