Skip to content

[BUG] KeyError of atomic_dipole or atom_dipole #3970

@marvcks

Description

@marvcks

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

Metadata

Metadata

Assignees

Labels

bugreproducedThis bug has been reproduced by developers

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions