dpdata
dpdata copied to clipboard
[Feature Request] Support property label format in dpdata
Summary
Until now, property fitting has been merged to deepmd-kit. But the training dataset is not supported to be converted from dpdata. Not like other labels, property does not have a general data source file.
Detailed Description
See above
Further Information, Files, and Links
See above
I don't have permission to assign myself
please check if the data registration mechanism (https://github.com/deepmodeling/dpdata/pull/505) solves the issue, if not what feature is needed to be implemented.
The data registration mechanism (https://github.com/deepmodeling/dpdata/pull/505) can solve the issue. A usage example:
import dpdata
import numpy as np
from dpdata.data_type import (
Axis,
DataType,
)
property_name = "band_prop" # fittng_net/property_name
task_dim = 3 # fitting_net/task_dim
# register datatype
datatypes = [
DataType(
property_name,
np.ndarray,
shape=(Axis.NFRAMES, task_dim),
required=False,
),
]
datatypes.extend(
[
DataType(
"energies",
np.ndarray,
shape=(Axis.NFRAMES, 1),
required=False,
),
DataType(
"forces",
np.ndarray,
shape=(Axis.NFRAMES, Axis.NATOMS, 1),
required=False,
),
]
)
for datatype in datatypes:
dpdata.System.register_data_type(datatype)
dpdata.LabeledSystem.register_data_type(datatype)
ls = dpdata.MultiSystems()
frame = dpdata.System("POSCAR", fmt="vasp/poscar")
labelframe = dpdata.LabeledSystem()
labelframe.append(frame)
labelframe.data[property_name] = np.array([[-0.236, 0.056, 0.292]], dtype=np.float32)
ls.append(labelframe)
ls.to_deepmd_npy_mixed("deepmd")