-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add example TensorMap
layout to TargetInfo
#370
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b8cd9ba
Add sample `TensorMap` to `TargetInfo`
frostedoyster 60b6b0d
Change `TensorMap`s inside `TargetInfo` to `float64` to avoid seriali…
frostedoyster 4c614f7
Better documentation
frostedoyster 172af0b
Upgrade to `metatensor-torch` 0.6.0
frostedoyster 0f3bfd7
Upgrade `metatensor-learn`
frostedoyster 0e8e2f7
Update strict NL
frostedoyster d632dc2
Fix PBCs
frostedoyster cf62ee7
Upgrade rascaline-torch
frostedoyster 0ebcc9a
Fix `slice` argument name
frostedoyster f7355dd
Merge branch 'upgrade-metatensor' into targetinfo-tensormap
frostedoyster f881951
Add dataset information overview to the dev docs
frostedoyster de9a28e
Fix docs
frostedoyster 4f89649
Merge branch 'main' into targetinfo-tensormap
frostedoyster ce0ee06
Review changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Dataset Information | ||
=================== | ||
|
||
When working with ``metatrain``, you will most likely need to interact with some core | ||
classes which are responsible for storing some information about datasets. All these | ||
classes belong to the ``metatrain.utils.data`` module which can be found in the | ||
:ref:`data` section of the developer documentation. | ||
|
||
These classes are: | ||
|
||
- :py:class:`metatrain.utils.data.DatasetInfo`: This class is responsible for storing | ||
information about a dataset. It contains the length unit used in the dataset, the | ||
atomic types present, as well as information about the dataset's targets as a | ||
``Dict[str, TargetInfo]`` object. The keys of this dictionary are the names of the | ||
targets in the datasets (e.g., ``energy``, ``mtt::dipole``, etc.). | ||
|
||
- :py:class:`metatrain.utils.data.TargetInfo`: This class is responsible for storing | ||
information about a target in a dataset. It contains the target's physical quantity, | ||
the unit in which the target is expressed, and the ``layout`` of the target. The | ||
``layout`` is ``TensorMap`` object with zero samples which is used to exemplify | ||
the metadata of each target. | ||
|
||
At the moment, only three types of layouts are supported: | ||
|
||
- scalar: This type of layout is used when the target is a scalar quantity. The | ||
``layout`` ``TensorMap`` object corresponding to a scalar must have one | ||
``TensorBlock`` and no ``components``. | ||
- Cartesian tensor: This type of layout is used when the target is a Cartesian tensor. | ||
The ``layout`` ``TensorMap`` object corresponding to a Cartesian tensor must have | ||
one ``TensorBlock`` and as many ``components`` as the tensor's rank. These | ||
components are named ``xyz`` for a tensor of rank 1 and ``xyz_1``, ``xyz_2``, and | ||
so on for higher ranks. | ||
- Spherical tensor: This type of layout is used when the target is a spherical tensor. | ||
The ``layout`` ``TensorMap`` object corresponding to a spherical tensor can have | ||
multiple blocks corresponding to different irreps (irreducible representations) of | ||
the target. The ``keys`` of the ``TensorMap`` object must have the ``o3_lambda`` | ||
and ``o3_sigma`` names, and each ``TensorBlock`` must have a single component named | ||
``o3_mu``. |
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 |
---|---|---|
|
@@ -12,5 +12,6 @@ module. | |
getting-started | ||
architecture-life-cycle | ||
new-architecture | ||
dataset-information | ||
cli/index | ||
utils/index |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Data | ||
==== | ||
|
||
.. _data: | ||
|
||
API for handling data in ``metatrain``. | ||
|
||
.. toctree:: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
) | ||
from ..utils.data import ( | ||
DatasetInfo, | ||
TargetInfoDict, | ||
TargetInfo, | ||
get_atomic_types, | ||
get_dataset, | ||
get_stats, | ||
|
@@ -227,11 +227,17 @@ | |
options["training_set"] = expand_dataset_config(options["training_set"]) | ||
|
||
train_datasets = [] | ||
target_infos = TargetInfoDict() | ||
for train_options in options["training_set"]: | ||
dataset, target_info_dict = get_dataset(train_options) | ||
target_info_dict: Dict[str, TargetInfo] = {} | ||
for train_options in options["training_set"]: # loop over training sets | ||
dataset, target_info_dict_single = get_dataset(train_options) | ||
train_datasets.append(dataset) | ||
target_infos.update(target_info_dict) | ||
intersecting_keys = target_info_dict.keys() & target_info_dict_single.keys() | ||
for key in intersecting_keys: | ||
if target_info_dict[key] != target_info_dict_single[key]: | ||
raise ValueError( | ||
f"Target information for key {key} differs between training sets." | ||
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. it would be nicer to add what the difference is here, so it is clear to the users |
||
) | ||
target_info_dict.update(target_info_dict_single) | ||
|
||
train_size = 1.0 | ||
|
||
|
@@ -320,7 +326,7 @@ | |
dataset_info = DatasetInfo( | ||
length_unit=options["training_set"][0]["systems"]["length_unit"], | ||
atomic_types=atomic_types, | ||
targets=target_infos, | ||
targets=target_info_dict, | ||
) | ||
|
||
########################### | ||
|
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
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.
I don't understand why these changes appear here, when they should already be on master. Could you squash this PR & rebase?
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.
I merged (saved me some time compared to rebasing). This should be gone