Closed iProzd closed 1 month ago
source/tests/pt/model/test_forward_lower.py (2)
`170-171`: Doubling the `sel` parameter for virtual atoms in tests seems justified to avoid large errors. Ensure this adjustment aligns with expected model behavior. --- `181-183`: Adjusting `nsel` parameters in `repinit` and `repformer` for virtual atoms in tests is noted. Verify that these changes do not adversely affect the model's expected behavior.deepmd/pt/model/network/init.py (9)
`182-193`: Using a no_grad wrapper in `zeros_` function aligns with best practices for tensor initialization. --- `196-207`: Using a no_grad wrapper in `ones_` function is correctly implemented. --- `210-226`: Proper use of no_grad wrapper and handling of torch function overrides in `constant_` function. --- `229-254`: Correct implementation of no_grad wrapper and torch function overrides in `normal_` function. --- `257-286`: Detailed and correct implementation of the truncated normal distribution in `trunc_normal_` function. --- `347-390`: Correct implementation of `kaiming_normal_` function using the Kaiming normal distribution. --- `393-422`: Correct implementation of `xavier_uniform_` function using the Xavier uniform distribution. --- `425-454`: Correct implementation of `xavier_normal_` function using the Xavier normal distribution. --- `289-344`: Implementation of `kaiming_uniform_` function is correct. Verify the calculations of `fan` and `gain` to ensure they are accurate.Verification successful
--- The implementations of `calculate_gain` and `_calculate_correct_fan` have been successfully extracted. Both functions appear to be correctly implemented according to the expected formulas for Kaiming initialization. - `calculate_gain` correctly returns the gain values for different nonlinearities, including `relu`, `leaky_relu`, and others. - `_calculate_correct_fan` correctly calculates the fan value based on the mode (`fan_in` or `fan_out`). The calculations of `fan` and `gain` in the `kaiming_uniform_` function are accurate.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the calculations of `fan` and `gain` in `kaiming_uniform_`. # Test: Search for usage of `fan` and `gain` calculations. Expect: Accurate calculations. rg --type python $'fan|gain' ``` Length of output: 60 --- --- Script: ```shell #!/bin/bash # Description: Verify the calculations of `fan` and `gain` in `kaiming_uniform_`. # Test: Search for definitions and usages of `fan` and `gain` in the codebase. rg 'fan|gain' ``` Length of output: 24010 --- --- Script: ```shell #!/bin/bash # Description: Extract the implementations of `calculate_gain` and `_calculate_correct_fan` from `deepmd/pt/model/network/init.py`. # Extract the implementation of `calculate_gain`. rg --pcre2 --multiline --multiline-dotall 'def calculate_gain\([^)]*\):.*?def ' deepmd/pt/model/network/init.py # Extract the implementation of `_calculate_correct_fan`. rg --pcre2 --multiline --multiline-dotall 'def _calculate_correct_fan\([^)]*\):.*?def ' deepmd/pt/model/network/init.py ``` Length of output: 3364
Attention: Patch coverage is 0%
with 167 lines
in your changes are missing coverage. Please review.
Project coverage is 35.63%. Comparing base (
81b5949
) to head (ad594b6
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I approve this PR, but it looks to me that
seed
is not passed from descriptors/fittings to the network in dpmodel, which needs to be fixed in the future.
an issue is necessary before this PR can be merged.
I approve this PR, but it looks to me that
seed
is not passed from descriptors/fittings to the network in dpmodel, which needs to be fixed in the future.an issue is necessary before this PR can be merged.
I've opened an issue about this: #3799
Summary by CodeRabbit
New Features
Improvements
seed
parameter in initialization methods and classes.get_generator
function for random seed management.Bug Fixes