Skip to content

Commit

Permalink
tutorials error removed
Browse files Browse the repository at this point in the history
  • Loading branch information
sundusaijaz committed Jan 14, 2025
1 parent 61ddf00 commit 8592067
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions examples/tutorials/tutorial_01_preparing_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -348,21 +348,18 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"To get a better initialization of the network and avoid numerical issues, we often want to make use of simple statistics of our target properties. The most simple approach is to subtract the mean value of our target property from the labels before training such that the neural networks only have to learn the difference from the mean prediction. A more sophisticated approach is to use so-called atomic reference values that provide basic statistics of our target property based on the atom types in a structure. This is especially useful for extensive properties such as the energy, where the single atom energies contribute a major part to the overall value. If your data comes with atomic reference values, you can add them to the metadata of your `ase` database. The statistics have to be stored in a dictionary with the property names as keys and the atomic reference values as lists where the list indices match the atomic numbers. For further explanation please have a look at the [QM9 tutorial](https://schnetpack.readthedocs.io/en/latest/tutorials/tutorial_02_qm9.html).\n",
"\n",
"Here is an example:"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# calculate this at the same level of theory as your data\n",
Expand All @@ -379,16 +376,19 @@
"# property_unit_dict={'energy':'kcal/mol'},\n",
"# atomref=atomref\n",
"# )"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"In our concrete case, we only have an MD trajectory of a single system. Therefore, we don't need to specify an atomref, since removing the average energy will working as well."
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -447,21 +447,17 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"## Using your data for training\n",
"We have now used the class `ASEAtomsData` to create a new `ase` database for our custom data. `schnetpack.data.ASEAtomsData` is a subclass of `pytorch.data.Dataset` and could be utilized for training models with `pytorch`. However, we use `pytorch-lightning` to conveniently handle the training procedure for us. This requires us to wrap the dataset in a [LightningDataModule](https://lightning.ai/docs/pytorch/stable/data/datamodule.html). We provide a general purpose `AtomsDataModule` for atomic systems in `schnetpack.data.datamodule.AtomsDataModule`. The data module will handle the unit conversion, splitting, batching and the preprocessing of the data with `transforms`. We can instantiate the data module for our custom dataset with:"
]
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [],
"source": [
"import schnetpack as spk\n",
Expand All @@ -484,23 +480,27 @@
")\n",
"custom_data.prepare_data()\n",
"custom_data.setup()"
]
],
"metadata": {
"collapsed": false,
"is_executing": true
}
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Please note that for the general case it makes sense to use your dataset within command line interface (see: [here](https://schnetpack.readthedocs.io/en/latest/userguide/configs.html)). For some benchmark datasets we provide data modules with download functions and more utilities in `schnetpack.data.datasets`. Further examples on how to use the data modules is provided in the following sections.\n"
]
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python [conda env:spkdev] *",
"language": "python",
"name": "python3"
"name": "conda-env-spkdev-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -512,7 +512,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.8.11"
},
"nbsphinx": {
"execute": "never"
Expand Down

0 comments on commit 8592067

Please sign in to comment.