Closed JiQi535 closed 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
6759ffb
) 98.59% compared to head (32b6f73
) 98.61%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think it is an extremely bad practice to put this in the predict_structure method. The predict_structure should return the expected target of the model. You should put it in a different method.
Hi @JiQi535, thanks for your PR. I agree that we should have another class to extract features from structures instead of just putting in the function predict_structure, which is mainly for property prediction. Maybe we can call the new function "extract_features" and then we can also remove the unnecessary "final" option in the output_layer?
Thanks for the comments @shyuep @kenko911 . I have added a different method, featurize_structure
, and the predict_structure
method has been changed back to its original format to only return the expected target of the model.
By default, featurize_structure
now returns the "readout" layer output and the "gc_3" layer output of intensive and extensive M3GNet models, respectively. Also, tests are updated, and a ValueError is raised if output_layer
is not one of the allowed names in ["embedding", "gc_1", "gc_2", "gc_3", "readout", "final"].
There is just way too much code and this is poor software design.
@shyuep The two suggestions have been realized in the updated code. My edits do not change the default output of forward
method, so that other related codes, e.g., the Potential
class, do not need change. This requires the addition of an argument in the forward method, i.e., return_all_layer_output
. This implementation also does not increase the memory consumption of the forward
method when return_all_layer_output
is False as default.
Summary
In this PR, the
forward
method of M3GNet is modified so that intermediate outputs in "embedding", "gc_1", "gc_2", "gc_3", and "readout" layers can be extracted, while the "final" layer output stays as the default output. This allows the usage of M3GNet intermediate outputs as atom, bond, and structure features. Documentations and tests are provided.Major changes:
output_layer
into theforward
method.predict_structure
method.output_layer
into thepredict_structure
method.node_vec
is renamed tofield_vec
, as this variable can either be node feature or edge feature instead of just node feature, depending on the argumentfield
.Todos
Follow-up analysis for the effectiveness of atom features.
Checklist
ruff
.mypy
.duecredit
@due.dcite
decorators to reference relevant papers by DOI (example)