-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added option for continue training from checkpoint #49
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f7b77e
Added cli option for continue training
PicoCentauri 699d726
Added cli option for continue training
PicoCentauri bb54b84
Finalize continuation of training
frostedoyster ea3254e
Merge branch 'restart' of https://github.com/lab-cosmo/metatensor-mod…
frostedoyster 8c2dc5e
Fix some merge issues
frostedoyster 99e9abb
Address comments
frostedoyster 689bcae
Sue correct type for continue_from
PicoCentauri e03c5bd
Linter
frostedoyster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,7 +305,9 @@ def forward( | |
if output_name in outputs: | ||
atomic_energies[output_name] = apply_composition_contribution( | ||
output_layer(hidden_features), | ||
self.composition_weights[self.output_to_index[output_name]], | ||
self.composition_weights[ # type: ignore | ||
self.output_to_index[output_name] | ||
], | ||
) | ||
|
||
# Sum the atomic energies coming from the BPNN to get the total energy | ||
|
@@ -331,6 +333,29 @@ def set_composition_weights( | |
) -> None: | ||
"""Set the composition weights for a given output.""" | ||
# all species that are not present retain their weight of zero | ||
self.composition_weights[self.output_to_index[output_name]][ | ||
self.composition_weights[self.output_to_index[output_name]][ # type: ignore | ||
self.all_species | ||
] = input_composition_weights | ||
|
||
def add_output(self, output_name: str) -> None: | ||
"""Add a new output to the model.""" | ||
# add a new row to the composition weights tensor | ||
Comment on lines
+341
to
+342
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't be both in the docstring? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both? |
||
self.composition_weights = torch.cat( | ||
[ | ||
self.composition_weights, # type: ignore | ||
torch.zeros( | ||
1, | ||
self.composition_weights.shape[1], # type: ignore | ||
dtype=self.composition_weights.dtype, # type: ignore | ||
device=self.composition_weights.device, # type: ignore | ||
), | ||
] | ||
) # type: ignore | ||
self.output_to_index[output_name] = len(self.output_to_index) | ||
# add a new linear layer to the last layers | ||
hypers_bpnn = self.hypers["bpnn"] | ||
if hypers_bpnn["num_hidden_layers"] == 0: | ||
n_inputs_last_layer = hypers_bpnn["input_size"] | ||
else: | ||
n_inputs_last_layer = hypers_bpnn["num_neurons_per_layer"] | ||
self.last_layers[output_name] = LinearMap(self.all_species, n_inputs_last_layer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe adding a default=None, here changes it from a string.