Search

Search papers and lessons

Crystal Graph Convolutional Neural Networks for Material Property Prediction

Tian Xie, Jeffrey C. Grossman · 2017

Xie and Grossman turn a crystal into a graph of atoms and bonds and train a graph convolutional network on it, predicting DFT properties of inorganic crystals with errors near DFT's own accuracy.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Linear algebra
  • Architectures
  • Neural network basics
  • Classical mechanics
  • ReadReady to readNot yet

TL;DR

Materials scientists want to predict a crystal's properties, such as its formation energy or band gap, without running a costly quantum calculation for every candidate. Xie and Grossman represent a crystal as a graph whose nodes are atoms and whose edges are bonds, and train a graph convolutional network on that graph using density functional theory (DFT) results as labels. The model predicts eight properties with errors close to DFT's own error against experiment, and its atom-level outputs point to chemically sensible rules for designing perovskites.

Builds on: Graph Convolutional Network, Message Passing Neural Network, Convolutional Neural Network, Crystal Lattice, Periodic Boundary Conditions · Leads to: later graph-network models for molecules and materials, which keep the atoms-and-bonds graph as their input

Why it mattered

Most machine-learning models need a fixed-length list of numbers as input, and a crystal has no natural one: it can contain anything from one to two hundred atoms, from many elements, in a repeating cell. Before this paper, the usual fixes were hand-made feature lists tailored to each property, or complicated coordinate transformations that made the model hard to read.

The paper's aim was a representation that works for any crystal and keeps the chemistry visible. It trained on about 46,700 inorganic crystals from the Materials Project database, covering 87 elements and 216 space groups, and reports that 90 percent of the crystals are binary, ternary or quaternary compounds. Its code is public at github.com/txie-93/cgcnn, and the work appeared in Physical Review Letters.

The problem

Two bottlenecks stood in the way.

  • Fixed-length inputs. A feature vector has to be built for each crystal before a standard model can read it. Hand-built vectors work for one property and have to be redesigned for the next, which the authors call case-by-case design.
  • Interpretability. Symmetry-invariant transformations of atomic positions handle any crystal, but after several non-linear layers it is hard to say which atom or which bond caused a prediction. A designer who gets a number cannot learn much from it.

The paper's answer is to keep the crystal's own connectivity as the input. The graph view of a crystal already fixes the size problem, because a graph can have any number of nodes, and it keeps each atom and bond as a separate object the model can talk about.

How it works

Take the rock-salt crystals sodium chloride (NaCl) and potassium chloride (KCl). The supplement uses them to show the whole method in miniature, and that is the version traced here. We need one graph, one convolution, one pooling step and one output.

  1. Turn the crystal into a graph. Each atom becomes a node with a feature vector that encodes its element: group number, period, electronegativity and so on, one-hot encoded. Each bond becomes an edge with a feature vector that encodes the distance between the two atoms. Check: in NaCl every sodium has six chlorine neighbours and every chlorine has six sodium neighbours, so the graph has six edges per node.
  2. Give each atom a starting feature. In the toy version, chlorine's feature is the one-hot vector (1, 0, 0), sodium's is (0, 1, 0), and potassium's is (0, 0, 1). Check: each node has exactly one entry equal to one.
  3. Convolve once. The convolution updates an atom from its own feature and from its neighbours' features, combined with weights the network learns. For one sodium atom with six chlorine neighbours, the update in the supplement gives 6wc1+ws26 w_{c1} + w_{s2}. The 66 comes from summing six neighbour vectors that are each (1,0,0)(1, 0, 0), and the ws2w_{s2} term is the atom's own feature multiplied by its self weight. Check: the sodium's new feature depends only on the chlorine neighbours and its own feature, which is what a local rule should do.
  4. Pool the atoms into one crystal vector. Average the atom features over the whole cell, so the crystal's vector does not depend on how many atoms the cell contains or on which atom is listed first. For NaCl the eight atoms average to 3wc1+3wc2+0.5ws1+0.5ws23 w_{c1} + 3 w_{c2} + 0.5 w_{s1} + 0.5 w_{s2}. Check: double the cell with the same atoms and each coefficient stays the same, because the average is unchanged.
  5. Predict. Because this toy model has no hidden layers, the pooled number is the prediction. Choose weights so the NaCl score is +1+1 and the KCl score is −1-1. One choice is wc2=1/3w_{c2} = 1/3 and wc3=−1/4w_{c3} = -1/4, with the others zero. Then NaCl gives 3⋅13=13 \cdot \frac{1}{3} = 1, and KCl gives 4⋅(−14)=−14 \cdot (-\frac{1}{4}) = -1. Check: the two crystals end up on opposite sides of zero, so the model separates them.

Real crystals need many convolutions, hidden layers and a continuous output, but the walkthrough shows the three ideas that carry over: the atom and bond features, the local update, and the pooling that makes the result a single vector for the whole crystal.

flowchart LR
  A["Crystal structure"] --> B["Crystal graph: atoms as nodes, bonds as edges"]
  B --> C["R convolutions update each atom from its neighbours"]
  C --> D["Pooling averages atom features into one crystal vector"]
  D --> E["Hidden layers and output give the predicted property"]

The math

Definition: Crystal graph

A crystal graph G\mathcal{G} is an undirected multigraph. Node ii has a feature vector vi\bm{v}_{i} describing its atom, and edge (i,j)k(i, j)_{k} has a feature vector u(i,j)k\bm{u}_{(i,j)_{k}} describing the kk-th bond between atoms ii and jj. Multiple edges between the same pair are allowed, because a periodic crystal can connect two atoms through several images of the cell.

Step 3 in symbols: the convolution

The general update has the form vi(t+1)=Conv(vi(t),vj(t),u(i,j)k)\bm{v}_{i}^{(t+1)} = \mathrm{Conv}(\bm{v}_{i}^{(t)}, \bm{v}_{j}^{(t)}, \bm{u}_{(i,j)_{k}}) over the neighbours jj of ii. The first convolution the authors try sums over neighbours before multiplying by a weight matrix, with ⊕\oplus meaning concatenation, Wc\bm{W}_c a convolution weight, Ws\bm{W}_s a self weight, b\bm{b} a bias and gg an activation:

vi(t+1)=g[(∑j,kvj(t)⊕u(i,j)k)Wc(t)+vi(t)Ws(t)+b(t)]\bm{v}_{i}^{(t+1)} = g\left[\left(\sum_{j,k} \bm{v}_{j}^{(t)} \oplus \bm{u}_{(i,j)_{k}}\right) \bm{W}_{c}^{(t)} + \bm{v}_{i}^{(t)} \bm{W}_{s}^{(t)} + \bm{b}^{(t)}\right]

The weakness of this form is that one shared Wc\bm{W}_c treats every neighbour alike, whatever the bond length. The second, better convolution gives each neighbour its own learned gate. It builds the neighbour vector z(i,j)k=vi⊕vj⊕u(i,j)k\bm{z}_{(i,j)_{k}} = \bm{v}_{i} \oplus \bm{v}_{j} \oplus \bm{u}_{(i,j)_{k}} and then computes

vi(t+1)=vi(t)+∑j,kσ(z(i,j)k(t)Wf(t)+bf(t))⊙g(z(i,j)k(t)Ws(t)+bs(t))\bm{v}_{i}^{(t+1)} = \bm{v}_{i}^{(t)} + \sum_{j,k} \sigma\left(\bm{z}_{(i,j)_{k}}^{(t)} \bm{W}_{f}^{(t)} + \bm{b}_{f}^{(t)}\right) \odot g\left(\bm{z}_{(i,j)_{k}}^{(t)} \bm{W}_{s}^{(t)} + \bm{b}_{s}^{(t)}\right)

where ⊙\odot is element-wise multiplication and σ\sigma is the sigmoid. The gate σ\sigma takes values between 0 and 1 for each neighbour and feature, so a weak bond can be switched down without a separate rule for which bonds count.

−6−4−2024600.20.40.60.81xsigma(x)
  • sigma(x)
The gate sigma is near 0 for strongly negative inputs and near 1 for strongly positive ones, so each neighbour's contribution is scaled between nothing and all of it.

The authors add the atom's own vector vi(t)\bm{v}_{i}^{(t)} back in, which they say makes deeper networks easier to train because information can pass through unchanged.

Step 4 in symbols: pooling

After RR convolutions the atom vectors are vi(R)\bm{v}_{i}^{(R)} for i=1,…,Ni = 1, \ldots, N, where NN is the number of atoms in the primitive cell. The crystal vector is the normalised sum

vc=1N∑ivi(R)\bm{v}_{c} = \frac{1}{N} \sum_{i} \bm{v}_{i}^{(R)}

This satisfies two invariances the authors require: permuting the atom indices does not change the sum, and using a larger cell of the same crystal gives the same average.

Step 5 in symbols: the prediction and loss

Two fully connected hidden layers and an output layer map vc\bm{v}_{c} to the prediction y^\hat{y}. Training minimises a cost J(y,y^)J(y, \hat{y}) between the prediction and the DFT value yy over the weights W\bm{W}, using backpropagation and stochastic gradient descent:

min⁡WJ(y,f(C;W))\min_{\bm{W}} J\left(y, f(\mathcal{C}; \bm{W})\right)

Here ff is the whole network and C\mathcal{C} is the crystal. For a continuous property the cost is an error such as the absolute difference; for metal versus semiconductor the output uses a softmax and a cross-entropy cost.

Interpretability

If the last hidden layer is replaced by a single linear map to a scalar v~i\tilde{v}_{i} for each atom, the crystal prediction becomes an average of these local scalars, vc=1N∑iv~iv_c = \frac{1}{N} \sum_i \tilde{v}_i. Each v~i\tilde{v}_i can then be read as that atom's contribution to the property, which is how the perovskite analysis works. The paper reports that this simplification costs some accuracy.

Results

The main result is the accuracy of the gated convolution on formation energy per atom. On the test set of 9,350 crystals the best mean absolute error (MAE) is 0.039 eV/atom, against 0.136 eV/atom for the simpler convolution. The authors compare this with the DFT error against experiment, which Kirklin and colleagues put at 0.081 to 0.136 eV/atom, and conclude that the model is a reliable estimate of DFT.

Table 1 of the paper, all with the gated convolution and about 28,000 training crystals for most rows:

PropertyUnitModel MAEDFT MAE against experiment
Formation energyeV/atom0.0390.081 to 0.136
Absolute energyeV/atom0.072not given
Band gapeV0.3880.6
Fermi energyeV0.363not given
Bulk moduluslog(GPa)0.0540.050
Shear moduluslog(GPa)0.0870.069
Poisson rationone0.030not given

The elastic moduli, which had only 2,041 training crystals, have higher errors. The authors say that with about 10,000 training crystals, the accuracy of DFT against experiment can be expected for these properties too.

Other results:

  • Classification. Metal versus semiconductor reaches an area under the ROC curve of 0.95. At a threshold of 0.5, metal accuracy is 0.80, semiconductor accuracy is 0.95 and overall accuracy is 0.90.
  • Generalisation. On 1,585 newly uploaded crystals with elastic data, the model gives an MAE of 0.077 log(GPa) for bulk moduli and 0.114 log(GPa) for shear moduli.
  • Perovskites. With linear pooling, the perovskite model's test MAE for total energy above hull is 0.130 eV/atom, against 0.099 eV/atom with the full pooling layer. The site energies it learns show that large atoms from groups 13 to 15 are stable on the A site, in addition to the known stable region of groups 1 to 3.
  • Screening. The authors searched for perovskites with a synthesisability cutoff of 0.2 eV/atom above hull. Among 378 perovskites in the data set, 33 pass, which is about 8.7 percent. Among 18,928 perovskites in the database, the base rate of potentially synthesisable compounds is 228, about 1.2 percent. The ratio of these two rates is about 7, which the paper reports as its efficiency gain.

The limits are the paper's own. The accuracy depends on how much data is available, and the elastic results are weaker for that reason. The interpretable variant trades accuracy for readability. The 0.2 eV/atom cutoff is a heuristic that the authors justify with nitride examples, not a physical law, and the perovskite search is only as good as the DFT values it learns from.

Reading guide

For the graph-network background, read Graph Neural Network before the paper; for a related graph-network paper that is closer to the classic recipe, read Semi-Supervised Classification with Graph Convolutional Networks.

Check yourself

QuestionWhy does the crystal graph need edges that can repeat, unlike a molecular graph?Show answer

A crystal is periodic: the same pair of atoms can be bonded through several translated copies of the cell, so the graph has more than one edge between the same pair of nodes. A molecule has one bond between a given pair, so the paper says a molecular graph does not need this.

QuestionIn the NaCl walkthrough, one sodium atom has six chlorine neighbours and its own feature contributes w_s2. What is its updated feature after one convolution, and why is the coefficient 6 rather than 1?Show answer

The updated feature is 6wc1+ws26 w_{c1} + w_{s2}. The coefficient is 6 because the convolution sums one neighbour vector per bond, and each of the six chlorine neighbours contributes the one-hot vector (1, 0, 0), whose first entry multiplies wc1w_{c1}. The single ws2w_{s2} comes from the atom's own feature multiplied by its self weight.

QuestionUsing the NaCl pooled score 3 w_c1 + 3 w_c2 + 0.5 w_s1 + 0.5 w_s2, suppose w_c2 is 1/3 and all other weights are zero. What score does NaCl get, and why must pooling average rather than sum?Show answer

The score is 3⋅13=13 \cdot \frac{1}{3} = 1. Pooling averages so that the crystal vector does not grow with the number of atoms in the cell: a sum would give a 2 by 2 by 2 supercell of the same crystal a different score, while the average gives the same one.

QuestionA team uses the paper's linear-pooling variant to find perovskites and wants to know which atom in a candidate crystal lowers its energy most. Why does this variant support that question, and what does it cost?Show answer

Linear pooling makes the prediction a sum of per-atom scalars, so each atom's contribution can be read off directly. The cost is accuracy: the paper reports a test MAE of 0.130 eV/atom with linear pooling against 0.099 eV/atom with the full pooling layer.

Sources

Read the full paper

Tian Xie, Jeffrey C. Grossman, 2017. arXiv:1710.10324