Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

High level interface and neural network #50

Merged
merged 17 commits into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class

# pytest
.pytest_cache/

# C extensions
*.so

Expand Down Expand Up @@ -61,6 +64,7 @@ instance/
.scrapy

# Sphinx documentation
docs/build/
docs/_build/

# PyBuilder
Expand Down
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ install:
if [ ${TRAVIS_PYTHON_VERSION:0:1} = 3 ]; then
sudo apt-get install python3-numpy
pip3 install scipy
pip3 install ase
pip3 install scikit-learn
pip3 install tensorflow
python3 setup.py build
python3 setup.py install
pip3 install sphinx
Expand All @@ -41,6 +44,9 @@ install:
elif [ ${TRAVIS_PYTHON_VERSION} = "2.7" ]; then
sudo apt-get install python-numpy
pip2 install scipy
pip2 install ase
pip2 install scikit-learn
pip2 install tensorflow
python2 setup.py build
python2 setup.py install
pip2 install sphinx
Expand All @@ -53,10 +59,10 @@ install:


before_script:
- cd ${TRAVIS_BUILD_DIR}/tests/
- cd ${TRAVIS_BUILD_DIR}/test/

script:
- nosetests -v
- pytest -v

notifications:
email: false
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ QML is a Python2/3-compatible toolkit for representation learning of properties

#### Current list of contributors:
* Anders S. Christensen (University of Basel)
* Lars A. Bratholm (University of Bristol)
* Silvia Amabilino (University of Bristol)
* Felix A. Faber (University of Basel)
* Bing Huang (University of Basel)
* Lars A. Bratholm (University of Copenhagen)
* Alexandre Tkatchenko (University of Luxembourg)
* Klaus-Robert Müller (Technische Universität Berlin/Korea University)
* O. Anatole von Lilienfeld (University of Basel)

## 1) Citing QML:

Until the preprint is available from arXiv, please cite this GitHub repository as:

AS Christensen, LA Bratholm, FA Faber, B Huang, A Tkatchenko, KR Müller, OA von Lilienfeld (2017) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml
AS Christensen, LA Bratholm, S Amabilino, FA Faber, B Huang, GR Glowacki, OA von Lilienfeld (2018) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml


## 2) Get help:
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Current list of contributors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Anders S. Christensen (University of Basel)
- Lars A. Bratholm (University of Bristol)
- Silvia Amabilino (University of Bristol)
- Felix A. Faber (University of Basel)
- Bing Huang (University of Basel)
- Lars A. Bratholm (University of Copenhagen)
- Alexandre Tkatchenko (University of Luxembourg)
- Klaus-Robert Müller (Technische Universität Berlin/Korea University)
- David R. Glowacki (University of Bristol)
- O. Anatole von Lilienfeld (University of Basel)

1) Citing QML:
Expand All @@ -25,7 +25,7 @@ repository as:

::

AS Christensen, LA Bratholm, FA Faber, B Huang, A Tkatchenko, KR Müller, OA von Lilienfeld (2017) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml
AS Christensen, LA Bratholm, S Amabilino, FA Faber, B Huang, GR Glowacki, OA von Lilienfeld (2018) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml

2) Get help:
------------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/citation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Until the preprint is available from arXiv, please cite use of QML as:

::

AS Christensen, FA Faber, B Huang, LA Bratholm, A Tkatchenko, KR Müller, OA von Lilienfeld (2017) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml
AS Christensen, LA Bratholm, S Amabilino, FA Faber, B Huang, DR Glowacki, OA von Lilienfeld (2018) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml



11 changes: 6 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from __future__ import print_function
import os
import sys
print os.getcwd()
sys.path.insert(0, os.path.abspath('../../build/lib.linux-x86_64-2.7/'))
print(os.getcwd())
# sys.path.insert(0, os.path.abspath('../../build/lib.linux-x86_64-2.7/'))
import sphinx_rtd_theme

# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -47,17 +48,17 @@

# General information about the project.
project = u'QML'
copyright = u'2017, Anders S. Christensen'
copyright = u'2016-2018, Anders S. Christensen'
author = u'Anders S. Christensen'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
iversion = u'0.4.0'
iversion = u'0.5.0.0'
# The full version, including alpha/beta/rc tags.
release = u'0.4.0'
release = u'0.5.0.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
32 changes: 17 additions & 15 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Generating representations using the ``Compound`` class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following example demonstrates how to generate a representation via
the ``qml.Compound`` class.
the ``qml.data.Compound`` class.

.. code:: python

from qml.data import Compound

# Read in an xyz or cif file.
water = Compound(xyz="water.xyz")

Expand All @@ -31,7 +33,7 @@ Generating representations via the ``qml.representations`` module
.. code:: python

import numpy as np
from qml.representations import *
from qml.ml.representations import *

# Dummy coordinates for a water molecule
coordinates = np.array([[1.464, 0.707, 1.056],
Expand Down Expand Up @@ -86,7 +88,7 @@ The input for most of the kernels in QML is a numpy array, where the first dimen
.. code:: python

import numpy as np
from qml.kernels import gaussian_kernel
from qml.ml.kernels import gaussian_kernel

# Generate a numpy-array of the representation
X = np.array([c.representation for c in compounds])
Expand All @@ -106,7 +108,7 @@ The easiest way to calculate the kernel matrix using an explicit, local represen
.. code:: python

import numpy as np
from qml.kernels import get_local_kernels_gaussian
from qml.ml.kernels import get_local_kernels_gaussian

# Assume the QM7 dataset is loaded into a list of Compound()
for compound in qm7:
Expand Down Expand Up @@ -144,7 +146,7 @@ This input (the types of many-body terms) is generate via the ``get_slatm_mbtype

.. code:: python

from qml.representations import get_slatm_mbtypes
from qml.ml.representations import get_slatm_mbtypes

# Assume 'qm7' is a list of Compound() objects.
mbtypes = get_slatm_mbtypes([mol.nuclear_charges for compound in qm7])
Expand All @@ -155,11 +157,11 @@ This input (the types of many-body terms) is generate via the ``get_slatm_mbtype
# Generate the desired representation for each compound
compound.generate_slatm(mbtypes, local=True)

The ``local`` keyword in this example specifies that a local representation is produced. Alternatively the SLATM representation can be generate via the ``qml.representations`` module:
The ``local`` keyword in this example specifies that a local representation is produced. Alternatively the SLATM representation can be generate via the ``qml.ml.representations`` module:

.. code:: python

from qml.representations import generate_slatm
from qml.ml.representations import generate_slatm

# Dummy coordinates
coordinates = ...
Expand All @@ -178,7 +180,7 @@ Here ``coordinates`` is an Nx3 numpy array, and ``nuclear_charges`` is simply a
Generating the FCHL representation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The FCHL representation does not have an explicit representation in the form of a vector, and the kernel elements must be calculated analytically in a separate kernel function.
The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.fchl`` module.
The syntax is analogous to the explicit representations (e.g. Coulomb matrix, BoB, SLATM, etc), but is handled by kernels from the separate ``qml.ml.representations.fchl`` module.

The code below show three ways to create the input representations for the FHCL kernel functions.

Expand All @@ -199,12 +201,12 @@ First using the ``Compound`` class:
The dimensions of the array should be ``(number_molecules, size, 5, size)``, where ``size`` is the
size keyword used when generating the representations.

In addition to using the ``Compound`` class to generate the representations, FCHL representations can also be generated via the ``qml.fchl.generate_fchl_representation()`` function, using similar notation to the functions in the ``qml.representations.*`` functions.
In addition to using the ``Compound`` class to generate the representations, FCHL representations can also be generated via the ``qml.ml.representations.fchl.generate_fchl_representation()`` function, using similar notation to the functions in the ``qml.ml.representations.*`` functions.


.. code:: python

from qml.fchl import generate_representation
from qml.ml.representations.fchl import generate_representation

# Dummy coordinates for a water molecule
coordinates = np.array([[1.464, 0.707, 1.056],
Expand All @@ -221,7 +223,7 @@ To create the representation for a crystal, the notation is as follows:

.. code:: python

from qml.fchl import generate_representation
from qml.ml.representations.fchl import generate_representation

# Dummy fractional coordinates
fractional_coordinates = np.array(
Expand Down Expand Up @@ -266,7 +268,7 @@ The following example demonstrates how to calculate the local FCHL kernel elemen

.. code:: python

from qml.fchl import get_local_kernels
from qml.ml.representations.fchl import get_local_kernels

# You can get kernels for multiple kernel-widths
sigmas = [2.5, 5.0, 10.0]
Expand All @@ -288,7 +290,7 @@ In case ``X1`` and ``X2`` are identical, K will be symmetrical. This is handled

.. code:: python

from qml.fchl import get_local_symmetric_kernels
from qml.ml.representations.fchl import get_local_symmetric_kernels

# You can get kernels for multiple kernel-widths
sigmas = [2.5, 5.0, 10.0]
Expand All @@ -307,8 +309,8 @@ In addition to the local kernel, the FCHL module also provides kernels for atomi

.. code:: python

from qml.fchl import get_atomic_kernels
from qml.fchl import get_atomic_symmetric_kernels
from qml.ml.representations.fchl import get_atomic_kernels
from qml.ml.representations.fchl import get_atomic_symmetric_kernels

The only difference between the local and atomic kernels is the shape of the input.
Since the atomic kernel outputs kernels with atomic resolution, the atomic input has the shape ``(number_atoms, 5, size)``.
16 changes: 8 additions & 8 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ QML: A Python Toolkit for Quantum Machine Learning
==================================================

QML is a Python2/3-compatible toolkit for representation learning of
properties of molecules and solids. QML is not a high-level framework
where you can do ``model.train()``, but supplies the building blocks to
properties of molecules and solids. QML supplies the the building blocks to
carry out efficient and accurate machine learning on chemical compounds.
As such, the goal is to provide usable and efficient implementations of
concepts such as representations and kernels.
The goal is to provide usable and efficient implementations of
concepts such as representations and kernels as well as a high level interface
to make it easy for computational chemists to use these for machine-learning tasks.


Current list of contributors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Anders S. Christensen (University of Basel)
- Lars A. Bratholm (University of Bristol)
- Silvia Amabilino (University of Bristol)
- Felix A. Faber (University of Basel)
- Bing Huang (University of Basel)
- Lars A. Bratholm (University of Copenhagen)
- Alexandre Tkatchenko (University of Luxembourg)
- Klaus-Robert Müller (Technische Universität Berlin/Korea University)
- David R. Glowacki (University of Bristol)
- O. Anatole von Lilienfeld (University of Basel)

Code development
Expand All @@ -48,7 +48,7 @@ Until the preprint is available from arXiv, please cite use of QML as:

::

AS Christensen, FA Faber, B Huang, LA Bratholm, A Tkatchenko, KR Müller, OA von Lilienfeld (2017) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml
AS Christensen, LA Bratholm, S Amabilino, FA Faber, B Huang, DR Glowacki, OA von Lilienfeld (2018) "QML: A Python Toolkit for Quantum Machine Learning" https://github.com/qmlcode/qml


For citation of the individual procedures of QML, please see the "Citing use of QML" section.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Installing prerequisite modules (for most Linux systems):

.. code:: bash

sudo apt-get install python-pip gfortran libblas-dev liblapack-dev git
sudo apt-get install python-pip gfortran libblas-dev liblapack-dev

These should already be installed on most systems. The Intel compilers
and MKL math-libraries are supported as well (see section 1.3).
Expand Down
22 changes: 15 additions & 7 deletions docs/source/qml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ Python API documentation
qml\.representations module
---------------------------

.. automodule:: qml.representations
.. automodule:: qml.ml.representations.representations
:members:
:undoc-members:
:show-inheritance:

qml\.kernels module
-------------------

.. automodule:: qml.kernels
.. automodule:: qml.ml.kernels
:members:
:undoc-members:
:show-inheritance:

qml\.distance module
--------------------

.. automodule:: qml.distance
.. automodule:: qml.ml.kernels.distance
:members:
:undoc-members:
:show-inheritance:

qml\.math module
----------------

.. automodule:: qml.math
.. automodule:: qml.ml.math
:members:
:undoc-members:
:show-inheritance:

qml\.Compound class
--------------------

.. autoclass:: qml.Compound
.. autoclass:: qml.data.compound.Compound
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -55,15 +55,15 @@ qml\.Compound class
qml\.fchl module
----------------

.. automodule:: qml.fchl
.. automodule:: qml.ml.representations.fchl
:members:
:show-inheritance:


qml\.wrappers module
--------------------

.. automodule:: qml.wrappers
.. automodule:: qml.ml.kernels.wrappers
:members:
:undoc-members:
:show-inheritance:
Expand All @@ -85,3 +85,11 @@ qml\.wrappers module
.. :undoc-members:
.. :show-inheritance:


qml\.aglaia module
------------------

.. automodule:: qml.aglaia.aglaia
:inherited-members:


Loading