forked from a-ws-m/unlockNN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
301 additions
and
160 deletions.
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 |
---|---|---|
|
@@ -13,4 +13,4 @@ python: | |
path: . | ||
|
||
sphinx: | ||
configuration: docs/source/conf.py | ||
configuration: docs/conf.py |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.. unlockGNN documentation master file, created by | ||
sphinx-quickstart on Wed Aug 18 15:33:30 2021. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
.. module:: unlockgnn | ||
|
||
What is unlockGNN? | ||
================== | ||
|
||
UnlockGNN is a Python package for adding uncertainty quantification to | ||
Keras models for materials property prediction. | ||
|
||
This documentation was built on |today|. | ||
|
||
Installation | ||
------------ | ||
|
||
Using ``pip``:: | ||
|
||
$ pip install unlockGNN | ||
|
||
From source | ||
^^^^^^^^^^^ | ||
|
||
First, clone the repository:: | ||
|
||
$ git clone https://github.com/a-ws-m/unlockGNN.git | ||
$ cd unlockGNN | ||
|
||
Then, either install dependencies using ``conda``:: | ||
|
||
$ conda env create -f environment.yml | ||
$ pip install . | ||
|
||
Or simply install using ``pip`` exclusively:: | ||
|
||
$ pip install . | ||
|
||
|
||
.. toctree:: | ||
:hidden: | ||
:caption: Modules | ||
|
||
modules/unlockgnn.model | ||
modules/unlockgnn.kernel_layers | ||
modules/unlockgnn.megnet_utils | ||
modules/unlockgnn.metrics | ||
modules/unlockgnn.initializers |
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,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
set BUILDDIR=_build | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
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,15 @@ | ||
.. currentmodule:: unlockgnn.initializers | ||
|
||
Inducing index points initializers | ||
================================== | ||
|
||
This experimental module contains work-in-progress algorithms for more intelligently | ||
initializing the locations of inducing index points | ||
for the variational Gaussian process (VGP). | ||
As per the `TensorFlow documentation <https://www.tensorflow.org/probability/api_docs/python/tfp/layers/VariationalGaussianProcess#args>`_, | ||
VGPs are highly sensitive to the location of these points, so improving the initializer could substantially increase performance. | ||
|
||
So far, only one custom initializer has been implemented and it does not seem to offer any performance improvement | ||
over the default initializer: | ||
|
||
.. autoclass:: SampleInitializer |
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 @@ | ||
.. currentmodule:: unlockgnn.kernel_layers | ||
|
||
Kernel layers | ||
============= | ||
|
||
UnlockGNN provides Keras-compatible implementations of a few kernel | ||
functions for use with the Gaussian process, as well as an extensible | ||
API for implementing your own kernels. | ||
|
||
Built-in kernels | ||
---------------- | ||
|
||
.. autosummary:: | ||
|
||
RBFKernelFn | ||
MaternOneHalfFn | ||
|
||
Each of these kernels can be saved using their :meth:`KernelLayer.save` method and then | ||
loaded using :func:`load_kernel`: | ||
|
||
.. autofunction:: load_kernel | ||
|
||
Extending the kernels API | ||
------------------------- | ||
|
||
All kernels must inherit from the :class:`KernelLayer` abstract base class: | ||
|
||
.. autoclass:: KernelLayer | ||
:members: | ||
:special-members: __init__ | ||
|
||
Both of the current built-in kernels are parameterized by an amplitude and | ||
a length scale. The :class:`AmpAndLengthScaleFn` abstract base class initializes | ||
these weights during instantiation and other kernels that are parameterized as | ||
such may inherit from this class also: | ||
|
||
.. autoclass:: AmpAndLengthScaleFn | ||
:special-members: __init__ |
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,6 @@ | ||
MEGNet utilities | ||
================ | ||
|
||
|
||
|
||
|
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,3 @@ | ||
Uncertainty quantification metrics | ||
================================== | ||
|
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,36 @@ | ||
.. currentmodule:: unlockgnn.model | ||
|
||
Probabilistic models | ||
==================== | ||
|
||
UnlockGNN includes an extensible interface for adding uncertainty quantification | ||
to any trained keras model using a | ||
`variational Gaussian process <https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/VariationalGaussianProcess>`_ | ||
(VGP). A VGP is a modification of a `Gaussian process <https://distill.pub/2019/visual-exploration-gaussian-processes>`_ | ||
that vastly improves model scalability; instead of using the entire training dataset | ||
as index points, a VGP uses variational inference to compute a smaller set of *inducing* index | ||
points that lead to a good approximation of the "full" Gaussian process. | ||
|
||
By supplanting the last layer(s) of a keras model with a VGP, the model's | ||
predictions become Gaussian distributions, rather than tensors. The mean of | ||
this distribution is the *de facto* "prediction" and the standard | ||
deviation indicates uncertainty. For example, two standard deviations | ||
gives the 95% confidence interval. | ||
|
||
.. note:: | ||
The caveat of using a VGP is that the probabilistic model must undergo | ||
further training to determine the inducing index point | ||
locations and the kernel parameters, which can be expensive! | ||
|
||
The module also contains a specific implementation for use with | ||
`MEGNet <https://github.com/materialsvirtuallab/megnet>`_, a highly performant | ||
graph neural network model for materials property prediction. | ||
|
||
MEGNet probabilistic model | ||
-------------------------- | ||
|
||
The bread and butter of unlockGNN, use :class:`MEGNetProbModel` to add uncertainty quantification | ||
to a :class:`MEGNetModel`: | ||
|
||
.. autoclass:: MEGNetProbModel | ||
:members: train, predict, evaluate, save, load, set_frozen, gnn_frozen, norm_frozen, vgp_frozen |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.