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] Cannot convert dipole model from TF to PT #3672

Open
njzjz opened this issue Apr 14, 2024 · 1 comment
Open

[BUG] Cannot convert dipole model from TF to PT #3672

njzjz opened this issue Apr 14, 2024 · 1 comment
Labels
bug reproduced This bug has been reproduced by developers
Milestone

Comments

@njzjz
Copy link
Member

njzjz commented Apr 14, 2024

Bug summary

An error throws when using dp convert-backend to convert a frozen dipole model from TF .pb format to PT .pth format.

DeePMD-kit Version

3eb3d51 (edit mode)

Backend and its version

TF 2.15.0, PT 2.1.2.post300

How did you download the software?

Built from source

Input Files, Running Commands, Error Log, etc.

Traceback (most recent call last):
  File "/home/jz748/anaconda3/bin/dp", line 8, in <module>
    sys.exit(main())
  File "/home/jz748/codes/deepmd-kit/deepmd/main.py", line 807, in main
    deepmd_main(args)
  File "/home/jz748/codes/deepmd-kit/deepmd/entrypoints/main.py", line 83, in main
    convert_backend(**dict_args)
  File "/home/jz748/codes/deepmd-kit/deepmd/entrypoints/convert_backend.py", line 26, in convert_backend
    data = inp_hook(INPUT)
  File "/home/jz748/codes/deepmd-kit/deepmd/tf/utils/serialization.py", line 47, in serialize_from_file
    model_dict = model.serialize()
  File "/home/jz748/codes/deepmd-kit/deepmd/tf/model/model.py", line 825, in serialize
    dict_fit = self.fitting.serialize(suffix=suffix)
  File "/home/jz748/codes/deepmd-kit/deepmd/tf/fit/dipole.py", line 375, in serialize
    "nets": self.serialize_network(
  File "/home/jz748/codes/deepmd-kit/deepmd/tf/fit/fitting.py", line 206, in serialize_network
    return fittings.serialize()
  File "/home/jz748/codes/deepmd-kit/deepmd/dpmodel/utils/network.py", line 769, in serialize
    "networks": [nn.serialize() for nn in self._networks],
  File "/home/jz748/codes/deepmd-kit/deepmd/dpmodel/utils/network.py", line 769, in <listcomp>
    "networks": [nn.serialize() for nn in self._networks],
AttributeError: 'NoneType' object has no attribute 'serialize'

Steps to Reproduce

cd examples/water_tensor/dipole
dp --tf train dipole_input.json
dp --tf freeze
dp convert-backend frozen_model.pb frozen_model.pth 

Further Information, Files, and Links

No response

@njzjz
Copy link
Member Author

njzjz commented Apr 15, 2024

I think I got the reason. Only types in sel_type have networks.

@iProzd iProzd moved this to Backlog in DeePMD-3.0.0 beta release Apr 30, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 5, 2024
Fix #2103. Migrate three models (se_e2_a, se_e2_r, and fparam_aparam)
for the Python unit tests. Fix several bugs. Old files are kept until
the C++ tests are also migrated.

Note that several models (for example, the dipole model due to #3672)
cannot be serialized yet.

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


## Summary by CodeRabbit

- **New Features**
- Introduced a structured framework for managing and testing models with
YAML files.
- Added comprehensive configurations for energy calculations and
molecular simulations in YAML format.
- Implemented new test cases for the `DeepPot` and `DeepPotNeighborList`
classes.

- **Bug Fixes**
- Improved robustness in tensor reshaping, resolving potential dimension
mismatches.

- **Tests**
- Enhanced unit tests with a case-based approach for better adaptability
and maintainability.
- Consolidated tests by relocating obsolete classes to streamline the
test suite.

- **Chores**
- Updated deserialization functions for better type safety and input
handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
mtaillefumier pushed a commit to mtaillefumier/deepmd-kit that referenced this issue Sep 18, 2024
Fix deepmodeling#2103. Migrate three models (se_e2_a, se_e2_r, and fparam_aparam)
for the Python unit tests. Fix several bugs. Old files are kept until
the C++ tests are also migrated.

Note that several models (for example, the dipole model due to deepmodeling#3672)
cannot be serialized yet.

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


## Summary by CodeRabbit

- **New Features**
- Introduced a structured framework for managing and testing models with
YAML files.
- Added comprehensive configurations for energy calculations and
molecular simulations in YAML format.
- Implemented new test cases for the `DeepPot` and `DeepPotNeighborList`
classes.

- **Bug Fixes**
- Improved robustness in tensor reshaping, resolving potential dimension
mismatches.

- **Tests**
- Enhanced unit tests with a case-based approach for better adaptability
and maintainability.
- Consolidated tests by relocating obsolete classes to streamline the
test suite.

- **Chores**
- Updated deserialization functions for better type safety and input
handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
@njzjz njzjz modified the milestones: v3.0.0, v3.1.0 Oct 28, 2024
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
Status: Backlog
Development

No branches or pull requests

1 participant