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

[Feature Request] Support property label format in dpdata #726

Closed
Chengqian-Zhang opened this issue Sep 19, 2024 · 3 comments
Closed

[Feature Request] Support property label format in dpdata #726

Chengqian-Zhang opened this issue Sep 19, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Chengqian-Zhang
Copy link
Contributor

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

@Chengqian-Zhang Chengqian-Zhang added the enhancement New feature or request label Sep 19, 2024
@Chengqian-Zhang
Copy link
Contributor Author

Chengqian-Zhang commented Sep 19, 2024

I don't have permission to assign myself

@wanghan-iapcm
Copy link
Contributor

please check if the data registration mechanism (#505) solves the issue, if not what feature is needed to be implemented.

@Chengqian-Zhang
Copy link
Contributor Author

The data registration mechanism (#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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants