-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add cgcnn framework * Add crystals to properties * Apply style on cgcnn framework * Add descriptions for crystal properties * Add training pipeline for cgcnn * Apply style * Update documentation * Add cgcnn training unit test and fix style * Enable cgcnn models * Increase samples_for_evaluation in the parameters * Rename CGCNN classes * Apply renaming in the cgccn unit test * Added the cgcnn properties to the factory for properties * Add examples for cgccn training * Proper handling of the classification output * Added cgcnn notebook * Apply style * Fix import in properties Co-authored-by: Jannis Born <[email protected]>
- Loading branch information
1 parent
2e6463d
commit 608f9a7
Showing
27 changed files
with
3,741 additions
and
1 deletion.
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,43 @@ | ||
## Crystals | ||
|
||
A simple example to train CGCNN based models to predict material properties. | ||
|
||
Make sure to activate the conda environment: | ||
|
||
```console | ||
conda activate gt4sd | ||
``` | ||
|
||
To launch a training execute the following command from the GT4SD root. Examples of a dataset, including he sample-classification that we use in the given example, can be found in the CGCNN's official implementation repo in the following [link](https://github.com/txie-93/cgcnn/tree/master/data). | ||
|
||
```console | ||
|
||
gt4sd-trainer --training_pipeline_name cgcnn \ | ||
--task classification \ | ||
--datapath sample-classification \ | ||
--atom_fea_len 64 \ | ||
--h_fea_len 128 \ | ||
--n_conv 3 \ | ||
--n_h 1 \ | ||
--epochs 30 \ | ||
--batch_size 256 \ | ||
--lr 0.01 \ | ||
--momentum 0.9 \ | ||
--weight_decay 0.0 \ | ||
--optim SGD | ||
``` | ||
|
||
The code is adapted from: <https://github.com/txie-93/cgcnn>. | ||
|
||
```bibtex | ||
@article{xie2018crystal, | ||
title={Crystal graph convolutional neural networks for an accurate and interpretable prediction of material properties}, | ||
author={Xie, Tian and Grossman, Jeffrey C}, | ||
journal={Physical review letters}, | ||
volume={120}, | ||
number={14}, | ||
pages={145301}, | ||
year={2018}, | ||
publisher={APS} | ||
} | ||
``` |
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,228 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Inference using CGCNN Model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"In this notebook we show how to perform inference using GT4SD and CGCNN-based models. The current existing models (algorithm_version=v0) and the sample dataset have been obtained from the [official CGCNN repository](https://github.com/txie-93/cgcnn)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Formation Energy\n", | ||
"\n", | ||
"This method predicts the formation energy per atom using the CGCNN framework (unit eV/atom)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import FormationEnergyParameters, FormationEnergy\n", | ||
"\n", | ||
"model_parameters = FormationEnergyParameters(algorithm_version=\"v0\")\n", | ||
"model = FormationEnergy(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Absolute Energy\n", | ||
"\n", | ||
"This method predicts the absolute energy of crystals using the CGCNN framework (unit eV/atom)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import AbsoluteEnergy, AbsoluteEnergyParameters\n", | ||
"\n", | ||
"model_parameters = AbsoluteEnergyParameters(algorithm_version=\"v0\")\n", | ||
"model = AbsoluteEnergy(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Band Gap\n", | ||
"\n", | ||
"This method predicts the band gap of crystals using the CGCNN framework (unit eV)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import BandGapParameters, BandGap\n", | ||
"\n", | ||
"model_parameters = BandGapParameters(algorithm_version=\"v0\")\n", | ||
"model = BandGap(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Fermi Energy\n", | ||
"\n", | ||
"This method predicts the Fermi energy of crystals using the CGCNN framework (unit eV/atom)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import FermiEnergyParameters, FermiEnergy\n", | ||
"\n", | ||
"model_parameters = FermiEnergyParameters(algorithm_version=\"v0\")\n", | ||
"model = FermiEnergy(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Bulk Moduli\n", | ||
"\n", | ||
"This method predicts the bulk moduli of crystals using the CGCNN framework (unit log(GPa))." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import BulkModuliParameters, BulkModuli\n", | ||
"\n", | ||
"model_parameters = BulkModuliParameters(algorithm_version=\"v0\")\n", | ||
"model = BulkModuli(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Shear Moduli\n", | ||
"\n", | ||
"This method predicts the shear moduli of crystals using the CGCNN framework (unit log(GPa))." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import ShearModuliParameters, ShearModuli\n", | ||
"\n", | ||
"model_parameters = ShearModuliParameters(algorithm_version=\"v0\")\n", | ||
"model = ShearModuli(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Poisson Ratio\n", | ||
"\n", | ||
"This method predicts the poisson ratio of crystals using the CGCNN framework." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import PoissonRatioParameters, PoissonRatio\n", | ||
"\n", | ||
"model_parameters = PoissonRatioParameters(algorithm_version=\"v0\")\n", | ||
"model = PoissonRatio(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Metal-Semiconductor classifier\n", | ||
"\n", | ||
"This method predicts if the provided crystals are metal (1) or semiconductors (0) using the CGCNN framework." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from gt4sd.properties.crystals.core import MetalSemiconductorClassifierParameters, MetalSemiconductorClassifier\n", | ||
"\n", | ||
"model_parameters = MetalSemiconductorClassifierParameters(algorithm_version=\"v0\")\n", | ||
"model = MetalSemiconductorClassifier(model_parameters)\n", | ||
"\n", | ||
"model(input=\"cgcnn-sample\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.15" | ||
}, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "7f6df040e92be56c42e1ba5ffdd58832f97e24eff2af0498cbc88845f2e95a48" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.