Grammar Variational Autoencoder | AGIDaily
AGI Daily
资讯日报词条论文人物新创
返回论文列表
摘要1. 引言2. 背景2.1. 变分自编码器2.2. 上下文无关文法3. 方法3.1. 一个示意例子3.2. 训练4. 实验4.1. 问题4.2. 潜空间的可视化4.3. 贝叶斯优化4.4. 潜表示的预测性能5. 相关工作6. 讨论致谢参考文献
返回论文列表
目录

Grammar Variational Autoencoder

收录于 ICML 2017 会议论文被引 1,086 次
打开论文来源

Grammar Variational Autoencoder

语法变分自编码器

Matt J. Kusner * 1 2 Brooks Paige * 1 3 José Miguel Hernández-Lobato 3

*Equal contribution 1Alan Turing Institute 2University of Warwick 3University of Cambridge. Correspondence to: mkusner@turing.ac.uk, bpaige@turing.ac.uk, jmh233@cam.ac.uk.

Proceedings of the 34 th International Conference on Machine Learning, Sydney, Australia, PMLR 70, 2017. Copyright 2017 by the author(s).

Abstract

摘要

Deep generative models have been wildly successful at learning coherent latent representations for continuous data such as natural images, artwork, and audio. However, generative modeling of discrete data such as arithmetic expressions and molecular structures still poses significant challenges. Crucially, state-of-the-art methods often produce outputs that are not valid. We make the key observation that frequently, discrete data can be represented as a parse tree from a context-free grammar. We propose a variational autoencoder which directly encodes from and decodes to these parse trees, ensuring the generated outputs are always syntactically valid. Surprisingly, we show that not only does our model more often generate valid outputs, it also learns a more coherent latent space in which nearby points decode to similar discrete outputs. We demonstrate the effectiveness of our learned models by showing their improved performance in Bayesian optimization for symbolic regression and molecule generation.

深度生成模型在为自然图像、艺术作品和音频这类连续数据学习连贯的潜表示上,已经取得非常突出的结果。但对算术表达式、分子结构这类离散数据做生成建模,仍然很困难。关键问题是,当时最好的方法也经常给出不合法的输出。我们观察到,离散数据常常可以写成一棵来自上下文无关文法(context-free grammar)的解析树。我们提出一种变分自编码器,直接从这些解析树编码、也解码回这些解析树,从而保证生成结果在句法上始终合法。更意外的是,模型不仅更经常给出合法输出,还学到了更连贯的潜空间:邻近的点会解码成相近的离散对象。我们在符号回归和分子生成的贝叶斯优化里检验了学到的模型,结果显示性能有所提升。

1. Introduction

1. 引言

Generative machine learning models have been used recently to produce extraordinary results, from realistic musical improvisation (Jaques et al., 2016), to changing facial expressions in images (Radford et al., 2015; Upchurch et al., 2016), to creating realistic looking artwork (Gatys et al., 2015). In large part, these generative models have been successful at representing data in continuous domains. Recently there is increased interest in training generative models to construct more complex, discrete data types such as arithmetic expressions (Kusner & Hernández-Lobato, 2016), source code (Gaunt et al., 2016; Riedel et al., 2016) and molecules (Gómez-Bombarelli et al., 2016b).

生成式机器学习模型近来做出过不少出色结果:从比较逼真的音乐即兴(Jaques et al., 2016),到改写图像里的表情(Radford et al., 2015; Upchurch et al., 2016),再到生成看起来真实的艺术作品(Gatys et al., 2015)。这些成功大多发生在连续数据上。近来也有更多工作想用生成模型去构造更复杂的离散对象,例如算术表达式(Kusner & Hernández-Lobato, 2016)、源代码(Gaunt et al., 2016; Riedel et al., 2016)和分子(Gómez-Bombarelli et al., 2016b)。

To train generative models for these tasks, these objects are often first represented as strings. This is in large part due to the fact that there exist powerful models for text sequence modeling such as Long Short Term Memory networks (LSTMs) (Hochreiter & Schmidhuber, 1997), Gated Recurrent Units (GRUs) (Cho et al., 2014), and Dynamic Convolutional Neural Networks (DCNNs) (Kalchbrenner et al., 2014). For instance, molecules can be represented by so-called SMILES strings (Weininger, 1988) and Gómez-Bombarelli et al. (2016b) has recently developed a generative model for molecules based on SMILES strings that uses GRUs and DCNNs. This model is able to encode and decode molecules to and from a continuous latent space, allowing one to search this space for new molecules with desirable properties (Gómez-Bombarelli et al., 2016b).

做这些任务时,对象常常先被写成字符串。一个重要原因是,文本序列模型已经很强,例如长短期记忆网络(LSTM)(Hochreiter & Schmidhuber, 1997)、门控循环单元(GRU)(Cho et al., 2014)和动态卷积神经网络(DCNN)(Kalchbrenner et al., 2014)。分子可以用所谓的 SMILES 串来表示(Weininger, 1988);Gómez-Bombarelli et al. (2016b) 最近就基于 SMILES,用 GRU 和 DCNN 做了一个分子生成模型。它能把分子编码进连续潜空间、再解码出来,从而在这个空间里搜索性质更好的新分子(Gómez-Bombarelli et al., 2016b)。

However, one immediate difficulty in using strings to represent discrete objects is that the representation is very brittle: small changes in the string can lead to completely different objects, or often do not correspond to valid objects at all. Specifically, Gómez-Bombarelli et al. (2016b) described that while searching for new molecules, the probabilistic decoder — the distribution which maps from the continuous latent space into the space of molecular structures — would sometimes accidentally put high probability on strings which are not valid SMILES strings or do not encode plausible molecules.

但用字符串表示离散对象,立刻会碰到一个困难:这种表示很脆。字符串上很小的改动,就可能对应完全不同的对象,也常常根本不是合法对象。Gómez-Bombarelli et al. (2016b) 就写到,在搜索新分子时,概率解码器——也就是从连续潜空间映到分子结构空间的那个分布——有时会偶然地把高概率放到并非合法 SMILES、或并不能编码出合理分子的字符串上。

To address this issue, we propose to directly incorporate knowledge about the structure of discrete data using a grammar. Grammars exist for a wide variety of discrete domains such as symbolic expressions (Allamanis et al., 2016), standard programming languages such as C (Kernighan et al., 1988), and chemical structures (James et al., 2015). For instance the set of syntactically valid SMILES strings is described using a context free grammar, which can be used for parsing and validation¹.

为了处理这个问题,我们建议直接用文法,把离散数据的结构知识写进模型。许多离散领域都有现成的文法,例如符号表达式(Allamanis et al., 2016)、C 这样的标准编程语言(Kernighan et al., 1988),以及化学结构(James et al., 2015)。句法合法的 SMILES 串集合就可以用上下文无关文法来描述,并用来做解析和校验。¹

¹ http://opensmiles.org/spec/open-smiles-2-grammar.html

Given a grammar, every valid discrete object can be described as a parse tree from the grammar. Thus, we propose the grammar variational autoencoder (GVAE) which encodes and decodes directly from and to these parse trees. Generating parse trees as opposed to strings ensures that all outputs are valid based on the grammar. This frees the GVAE from learning syntactic rules and allows it to wholly focus on learning other 'semantic' properties.

有了文法,每个合法的离散对象都可以写成该文法下的一棵解析树。因此我们提出语法变分自编码器(grammar variational autoencoder,GVAE),直接从这些解析树编码,也解码回这些解析树。生成的是解析树而不是字符串,就能保证输出按文法都是合法的。这样一来,GVAE 不必再去学习句法规则,可以把力量完全放在学习其他“语义”性质上。

We demonstrate the GVAE on two tasks for generating discrete data: 1) generating simple arithmetic expressions and 2) generating valid molecules. We show not only does our model produce a higher proportion of valid outputs than a character based autoencoder, it also produces smoother latent representations. We also show that this learned latent space is effective for searching for arithmetic expressions that fit data, for finding better drug-like molecules, and for making accurate predictions about target properties.

我们在两项离散数据生成任务上检验 GVAE:一是生成简单算术表达式,二是生成合法分子。结果显示,和基于字符的自编码器相比,我们的模型不仅给出更高比例的合法输出,学到的潜表示也更平滑。我们还表明,这个学到的潜空间可以用来搜索拟合数据的算术表达式、寻找更好的类药分子,并对目标性质做较准确的预测。

2. Background

2. 背景

2.1. Variational autoencoder

2.1. 变分自编码器

We wish to learn both an encoder and a decoder for mapping data xxx to and from values zzz in a continuous space. The variational autoencoder (Kingma & Welling, 2014; Rezende et al., 2014) provides a formulation in which the encoding zzz is interpreted as a latent variable in a probabilistic generative model; a probabilistic decoder is defined by a likelihood function pθ(x∣z)p_\theta(x|z)pθ​(x∣z) and parameterized by θ\thetaθ. Alongside a prior distribution p(z)p(z)p(z) over the latent variables, the posterior distribution pθ(z∣x)∝p(z)pθ(x∣z)p_\theta(z|x) \propto p(z)p_\theta(x|z)pθ​(z∣x)∝p(z)pθ​(x∣z) can then be interpreted as a probabilistic encoder.

我们希望同时学习编码器和解码器,把数据 xxx 映射到连续空间里的 zzz,再映射回来。变分自编码器(Kingma & Welling, 2014; Rezende et al., 2014)提供了一种写法:把编码 zzz 看成概率生成模型里的潜变量;概率解码器用似然 pθ(x∣z)p_\theta(x|z)pθ​(x∣z) 定义,参数是 θ\thetaθ。再加上潜变量上的先验 p(z)p(z)p(z),后验 pθ(z∣x)∝p(z)pθ(x∣z)p_\theta(z|x) \propto p(z)p_\theta(x|z)pθ​(z∣x)∝p(z)pθ​(x∣z) 就可以看成一个概率编码器。

To admit efficient inference, the variational Bayes approach simultaneously learns both the parameters of pθ(x∣z)p_\theta(x|z)pθ​(x∣z) as well as those of a posterior approximation qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x). This is achieved by maximizing the evidence lower bound (ELBO)

为了能够高效推断,变分贝叶斯方法会同时学习 pθ(x∣z)p_\theta(x|z)pθ​(x∣z) 的参数,以及后验近似 qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) 的参数。做法是最大化证据下界(ELBO)

L(ϕ,θ;x)=Eqϕ(z∣x)[log⁡pθ(x,z)−log⁡qϕ(z∣x)],(1)\mathcal{L}(\phi, \theta; x) = \mathbb{E}_{q_\phi(z|x)}[\log p_\theta(x, z) - \log q_\phi(z|x)], \tag{1}L(ϕ,θ;x)=Eqϕ​(z∣x)​[logpθ​(x,z)−logqϕ​(z∣x)],(1)

with L(ϕ,θ;x)≤log⁡pθ(x)\mathcal{L}(\phi, \theta; x) \leq \log p_\theta(x)L(ϕ,θ;x)≤logpθ​(x). So long as pθ(x∣z)p_\theta(x|z)pθ​(x∣z) and qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) can be computed pointwise, and are differentiable with respect to their parameters, the ELBO can be maximized via gradient descent; this allows wide flexibility in choice of encoder and decoder models. Typically these will take the form of exponential family distributions whose parameters are the weights of a multi-layer neural network.

并且 L(ϕ,θ;x)≤log⁡pθ(x)\mathcal{L}(\phi, \theta; x) \leq \log p_\theta(x)L(ϕ,θ;x)≤logpθ​(x)。只要 pθ(x∣z)p_\theta(x|z)pθ​(x∣z) 和 qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) 能逐点计算,并且对其参数可微,就可以用梯度下降最大化 ELBO;编码器和解码器因此可以选得很宽。它们通常会写成指数族分布,参数则是多层神经网络的权重。

2.2. Context-free grammars

2.2. 上下文无关文法

A context-free grammar (CFG) is traditionally defined as a 4-tuple G=(V,Σ,R,S)G = (V, \Sigma, R, S)G=(V,Σ,R,S): VVV is a finite set of non-terminal symbols; the alphabet Σ\SigmaΣ is a finite set of terminal symbols, disjoint from VVV; RRR is a finite set of production rules; and SSS is a distinct non-terminal known as the start symbol. The rules RRR are formally described as α→β\alpha \to \betaα→β for α∈V\alpha \in Vα∈V and β∈(V∪Σ)∗\beta \in (V \cup \Sigma)^*β∈(V∪Σ)∗, with ∗*∗ denoting the Kleene closure. In practice, these rules are defined as a set of mappings from a single left-hand side non-terminal in VVV to a sequence of terminal and/or non-terminal symbols, and can be interpreted as 'replacement' instructions.

上下文无关文法(CFG)通常写成四元组 G=(V,Σ,R,S)G = (V, \Sigma, R, S)G=(V,Σ,R,S):VVV 是有限的非终结符集合;字母表 Σ\SigmaΣ 是与 VVV 不相交的有限终结符集合;RRR 是有限的产生式集合;SSS 是一个特别的非终结符,称为开始符号。规则 RRR 形式上写成 α→β\alpha \to \betaα→β,其中 α∈V\alpha \in Vα∈V,β∈(V∪Σ)∗\beta \in (V \cup \Sigma)^*β∈(V∪Σ)∗,∗*∗ 表示克莱尼闭包。实践里,这些规则就是从 VVV 中单个左部非终结符到一串终结符和/或非终结符的映射,可以看成“替换”指令。

Repeatedly applying production rules beginning with a non-terminal symbol defines a tree, with symbols on the right-hand side of the production rule becoming child nodes for the left-hand side parent. The grammar GGG thus defines a set of possible trees extending from each non-terminal symbol in VVV, produced by recursively applying rules in RRR to leaf nodes until all leaf nodes are terminal symbols in Σ\SigmaΣ. The language of GGG is the set of all terminal symbol sequences that can be generated as leaf nodes in a tree. Given a string in the language (i.e., a sequence of terminals), a parse tree is a tree rooted at SSS which has this sequence of terminal symbols as its leaf nodes. The ubiquity of context-free languages in computer science is due in part to the presence of efficient parsing algorithms to generate parse trees. For more background on CFGs and automata theory, see e.g. Hopcroft et al. (2006).

从某个非终结符开始反复应用产生式,就会得到一棵树:产生式右部的符号成为左部父结点的子结点。这样,文法 GGG 就为 VVV 中每个非终结符定义了一族可能的树:不断把 RRR 中的规则作用到叶结点上,直到所有叶结点都是 Σ\SigmaΣ 中的终结符。GGG 的语言,就是所有能作为某棵树叶结点出现的终结符序列。给定语言中的一个串(也就是一串终结符),解析树是一棵以 SSS 为根、并以这串终结符为叶结点的树。上下文无关语言在计算机科学里如此常见,部分原因就是存在高效的解析算法来生成解析树。更多关于 CFG 和自动机理论的背景,可见 Hopcroft et al. (2006)。

Our work builds off the work of probabilistic context-free grammars (PCFGs). A PCFG assigns probabilities to each production rule in the grammar, and thus defines a probability distribution over parse trees (Baker, 1979; Booth & Thompson, 1973). A string can be generated by repeatedly sampling and applying production rules, beginning at the start symbol, until no non-terminals remain. Modern approaches allow the probabilities used at each stage to depend on the state of the parse tree (Johnson et al., 2007).

我们的工作建立在概率上下文无关文法(PCFG)之上。PCFG 给文法中的每条产生式分配概率,从而在解析树上定义一个概率分布(Baker, 1979; Booth & Thompson, 1973)。从开始符号出发,反复抽样并应用产生式,直到不再有非终结符,就可以生成一个字符串。较新的做法还允许每一步所用的概率依赖于当前解析树的状态(Johnson et al., 2007)。

3. Methods

3. 方法

In this section we describe how a grammar can improve variational autoencoders (VAE) for discrete data. It will do so by drastically reducing the number of invalid outputs generated from the VAE. We illustrate our approach on molecular data, however it will extend to any descrete data that can be described by a grammar.

这一节说明文法怎样改进用于离散数据的变分自编码器(VAE):它会大幅减少 VAE 生成的无效输出。我们用分子数据来演示,但这种方法可以推广到任何能用文法描述的离散数据。原文此处作 descrete。

One glaring issue with a character-based VAE is that it may frequently map latent points to sequences that are not valid, hoping the VAE will infer from training data what constitutes a valid sequence. Instead of implicitly encouraging the VAE to produce valid sequences, we propose to give the VAE explicit knowledge about how to produce valid sequences. We do this by using a grammar for the sequences: given a grammar we can take any valid sequence and parse it into a parse tree. A pre-order traversal on this parse tree yields a sequence of production rules. Applying these rules in order will yield the original sequence. Our approach then will be to learn a VAE that produces sequences of grammar production rules. The benefit is that it is trivial to generate valid sequences of production rules, as the grammar describes the valid set of rules that can be selected at any point during the generation process. Thus, our model is able to focus on learning semantic properties of sequence data without also having to learn syntactic constraints.

基于字符的 VAE 有一个明显问题:它常常会把潜空间中的点映射成不合法的序列,只能指望模型从训练数据里自己悟出什么叫合法。我们不再只靠隐式鼓励,而是直接告诉 VAE 怎样生成合法序列。具体做法是使用序列的文法:有了文法,任意合法序列都可以解析成一棵解析树;对这棵树做前序遍历,就得到一串产生式;再按顺序应用这些规则,就能还原原来的序列。于是我们学习一个生成文法产生式序列的 VAE。这样做的好处是,生成合法的产生式序列变得很直接,因为文法已经规定了生成过程中每一步还能选哪些规则。模型因此可以把力量放在学习序列数据的语义性质上,而不必同时学习句法约束。

GVAE 编码器:从 SMILES 文法到解析树、产生式、one-hot 再到潜空间

Figure 1. The encoder of the GVAE. We denote the start rule in blue and all rules that decode to terminal in green. See text for details.

图 1. GVAE 的编码器。开始规则用蓝色标出,解码到终结符的规则用绿色标出。细节见正文。

3.1. An illustrative example

3.1. 一个示意例子

We propose a grammar variational autoencoder (GVAE) that encodes/decodes in the space of grammar production rules. We describe how it works with a simple example.

我们提出语法变分自编码器(GVAE),在文法产生式的空间里做编码和解码。下面用一个简单例子说明它如何工作。

Encoding.

编码。

Consider a subset of the SMILES grammar as shown in Figure 1, box ①. These are the possible production rules that can be used for constructing a molecule. Imagine we are given as input the SMILES string for benzene: ‘c1ccccc1’. Figure 1, box ③ shows this molecule. To encode this molecule into a continuous latent representation we begin by using the SMILES grammar to parse this string into a parse tree (partially shown in box ②). This tree describes how ‘c1ccccc1’ is generated by the grammar. We decompose this tree into a sequence of production rules by performing a pre-order traversal on the branches of the parse tree from left-to-right, shown in box ④. We convert these rules into 1-hot indicator vectors, where each dimension corresponds to a rule in the SMILES grammar, box ⑤. These 1-hot vectors are concatenated into the rows of a matrix X\mathbf{X}X of dimension T(X)×KT(\mathbf{X}) \times KT(X)×K, where KKK is the number of production rules in the SMILES grammar, and T(X)T(\mathbf{X})T(X) is the number of production rules used to generate X\mathbf{X}X.

先看图 1 方框 ① 里给出的一部分 SMILES 文法。这些就是构造分子时可以用的产生式。假设输入是苯的 SMILES 串:‘c1ccccc1’。图 1 方框 ③ 画出了这个分子。要把它编成连续的潜表示,我们先用 SMILES 文法把这个串解析成一棵解析树(方框 ② 只画出一部分)。这棵树说明文法是怎样生成 ‘c1ccccc1’ 的。再对解析树的各枝从左到右做前序遍历,把树拆成一串产生式,见方框 ④。然后把这些规则写成 one-hot 指示向量,每个维度对应 SMILES 文法中的一条规则,见方框 ⑤。这些 one-hot 向量按行拼成矩阵 X\mathbf{X}X,尺寸是 T(X)×KT(\mathbf{X}) \times KT(X)×K,其中 KKK 是 SMILES 文法中的产生式条数,T(X)T(\mathbf{X})T(X) 是生成 X\mathbf{X}X 所用的产生式条数。

We use a deep convolutional neural network to map the collection of 1-hot vectors X\mathbf{X}X to a continuous latent vector z\mathbf{z}z. The architecture of the encoding network is described in the supplementary material.

我们用深层卷积神经网络,把这组 one-hot 向量 X\mathbf{X}X 映射成连续潜向量 z\mathbf{z}z。编码网络的结构写在补充材料里。

Decoding.

解码。

We now describe how we map continuous vectors back to a sequence of production rules (and thus SMILES strings). Crucially we construct the decoder so that, at any time while we are decoding a sequence, the decoder will only be allowed to select a subset of production rules that are ‘valid’. This will cause the decoder to only produce valid parse sequences from the grammar.

下面说明怎样把连续向量映回一串产生式(也就映回 SMILES 串)。关键是把解码器构造成:在解码序列的任何时刻,它只被允许选择当时“合法”的那一部分产生式。这样,解码器就只会生成符合文法的合法解析序列。

We begin by passing the continuous vector z\mathbf{z}z through a recurrent neural network which produces a set of unnormalized log probability vectors (or ‘logits’), shown in Figure 2, box ① and ②. Exactly like the 1-hot vectors produced by the encoder, each dimension of the logit vectors corresponds to a production rule in the grammar. We can again write these collection of logit vectors as a matrix F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K, where Tmax⁡T_{\max}Tmax​ is the maximum number of timesteps (production rules) allowed by the decoder. During the rest of the decoding operations, we will use the rows of F\mathbf{F}F to select a sequence of valid production rules.

首先把连续向量 z\mathbf{z}z 送进循环神经网络,得到一组未归一化的对数概率向量(也叫 logit),见图 2 方框 ① 和 ②。和编码器产出的 one-hot 向量一样,logit 向量的每个维度对应文法中的一条产生式。这组 logit 也可以写成矩阵 F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K,其中 Tmax⁡T_{\max}Tmax​ 是解码器允许的最大步数(也就是最多几条产生式)。后面的解码步骤里,我们用 F\mathbf{F}F 的各行来选择一串合法产生式。

To ensure that any sequence of production rules generated from the decoder is valid, we keep track of the state of the parsing using a last-in first-out (LIFO) stack. This is shown in Figure 2, box ③. At the beginning, every valid parse from the grammar must start with the start symbol: smiles, which is placed on the stack. Next we pop off whatever non-terminal symbol that was placed last on the stack (in this case smiles), and we use it to mask out the invalid dimensions of the current logit vector. Formally, for every non-terminal α\alphaα we define a fixed binary mask vector mα∈[0,1]K\mathbf{m}_\alpha \in [0, 1]^Kmα​∈[0,1]K. This takes the value ‘1’ for all indices in 1,…,K1, \ldots, K1,…,K corresponding to production rules that have α\alphaα on their left-hand-side.

为了保证解码器给出的产生式序列都合法,我们用一个后进先出(LIFO)栈来跟踪解析状态,见图 2 方框 ③。一开始,文法中任何合法解析都必须从开始符号 smiles 出发,于是把它放进栈里。接着弹出栈顶最近压入的那个非终结符(这里就是 smiles),用它把当前 logit 向量中不合法的维度掩掉。形式上,对每个非终结符 α\alphaα,我们定义一个固定的二值掩码向量 mα∈[0,1]K\mathbf{m}_\alpha \in [0, 1]^Kmα​∈[0,1]K。凡是左部为 α\alphaα 的产生式,对应维度取 ‘1’。

In the previous example, the only production rule in the grammar beginning with smiles is the first so we mask-out every dimension except the first, shown in Figure 2, box ④. We then sample from the remaining unmasked rules, using their values in the logit vector. To sample from this masked logit at any timestep ttt we form the following masked distribution:

在前面的例子里,文法中以 smiles 开头的产生式只有第一条,于是我们掩掉除第一维以外的所有维度,见图 2 方框 ④。然后在剩下未被掩掉的规则里,按 logit 向量中的取值做抽样。在任意时刻 ttt,从这个加了掩码的 logit 里抽样时,我们使用下面这个带掩码的分布:

p(xt=k∣α,z)=mα,k exp⁡(ftk)∑j=1Kmα,k exp⁡(ftj),(2)p(\mathbf{x}_t = k \mid \alpha, \mathbf{z}) = \frac{m_{\alpha,k}\,\exp(f_{tk})}{\sum_{j=1}^{K} m_{\alpha,k}\,\exp(f_{tj})}, \tag{2}p(xt​=k∣α,z)=∑j=1K​mα,k​exp(ftj​)mα,k​exp(ftk​)​,(2)

where ftkf_{tk}ftk​ is the (t,k)(t, k)(t,k)-element of the logit matrix F\mathbf{F}F. As only the first rule is unmasked we will select this rule smiles→chainsmiles \to chainsmiles→chain as the first rule in our sequence, box ⑤. Now the next rule must begin with chainchainchain, so we push it onto the stack (Figure 2, box ③). We sample this non-terminal and, as before, use it to mask out all of the rules that cannot be applied in the current logit vector. We then sample a valid rule from this logit vector: chain→chain, branched atomchain \to chain,\ branched\ atomchain→chain, branched atom. Just as before we push the non-terminals on the right-hand side of this rule onto the stack, adding the individual non-terminals in from right to left, such that the leftmost non-terminal is on the top of the stack. For the next state we again pop the last rule placed on the stack and mask the current logit, etc. This process continues until the stack is empty or we reach the maximum number of logit vectors Tmax⁡T_{\max}Tmax​. We describe this decoding procedure formally in Algorithm 1. In practice, because sampling from the decoder often finishes before ttt reaches Tmax⁡T_{\max}Tmax​, we introduce an additional ‘no-op’ rule to the grammar that we use to pad X\mathbf{X}X until the number of rows equals Tmax⁡T_{\max}Tmax​.

其中 ftkf_{tk}ftk​ 是 logit 矩阵 F\mathbf{F}F 的 (t,k)(t, k)(t,k) 元。因为只有第一条规则没被掩掉,我们会选 smiles→chainsmiles \to chainsmiles→chain 作为序列中的第一条规则,见方框 ⑤。下一条规则必须以 chainchainchain 开头,于是把它压进栈里(图 2 方框 ③)。我们取出这个非终结符,像前面一样用它掩掉当前 logit 向量里不能用的规则,再从中抽一条合法规则:chain→chain, branched atomchain \to chain,\ branched\ atomchain→chain, branched atom。同样,把这条规则右部的非终结符压栈,按从右到左的顺序逐个压入,让最左边的非终结符位于栈顶。进入下一状态时,再次弹出栈顶规则并掩蔽当前 logit,如此继续,直到栈空,或用完最多 Tmax⁡T_{\max}Tmax​ 个 logit 向量。算法 1 正式描述了这一解码过程。实践中,从解码器抽样常常在 ttt 到达 Tmax⁡T_{\max}Tmax​ 之前就结束了,于是我们给文法增加一条额外的 “no-op” 规则,用来把 X\mathbf{X}X 填到行数等于 Tmax⁡T_{\max}Tmax​。

GVAE 解码器:从潜空间到 logit、栈、掩码抽样并还原分子

Figure 2. The decoder of the GVAE. See text for details.

图 2. GVAE 的解码器。细节见正文。

Algorithm 1 Sampling from the decoder

Input: Deterministic decoder output F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K, masks mα\mathbf{m}_\alphamα​ for each production rule α\alphaα

Output: Sampled productions X\mathbf{X}X from p(X∣z)p(\mathbf{X}|\mathbf{z})p(X∣z)

1: Initialize empty stack S\mathcal{S}S, and push the start symbol SSS onto the top; set t=0t = 0t=0
2: while S\mathcal{S}S is nonempty do
3:   Pop the last-pushed non-terminal α\alphaα from the stack S\mathcal{S}S
4:   Use Eq. (2) to sample a production rule R\mathcal{R}R
5:   Let xt\mathbf{x}_txt​ be the 1-hot vector corresponding to R\mathcal{R}R
6:   Let RHS(R)\mathrm{RHS}(\mathcal{R})RHS(R) denote all non-terminals on the right-hand side of rule R\mathcal{R}R, ordered from right to left
7:   for non-terminal β\betaβ in RHS(R)\mathrm{RHS}(\mathcal{R})RHS(R) do
8:     Push β\betaβ on to the stack S\mathcal{S}S
9:   end for
10:   Set X←[X⊤,xt]⊤\mathbf{X} \leftarrow [\mathbf{X}^\top, \mathbf{x}_t]^\topX←[X⊤,xt​]⊤
11:   Set t←t+1t \leftarrow t + 1t←t+1
12: end while

算法 1 从解码器中抽样

输入: 确定性解码器输出 F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K,每条产生式 α\alphaα 对应的掩码 mα\mathbf{m}_\alphamα​

输出: 从 p(X∣z)p(\mathbf{X}|\mathbf{z})p(X∣z) 抽得的产生式 X\mathbf{X}X

1: 初始化空栈 S\mathcal{S}S,把开始符号 SSS 压到栈顶;令 t=0t = 0t=0
2: while S\mathcal{S}S 非空 do
3:   从栈 S\mathcal{S}S 弹出最近压入的非终结符 α\alphaα
4:   用式 (2) 抽样一条产生式 R\mathcal{R}R
5:   令 xt\mathbf{x}_txt​ 为与 R\mathcal{R}R 对应的 one-hot 向量
6:   令 RHS(R)\mathrm{RHS}(\mathcal{R})RHS(R) 表示规则 R\mathcal{R}R 右部的全部非终结符,按从右到左排序
7:   for RHS(R)\mathrm{RHS}(\mathcal{R})RHS(R) 中的非终结符 β\betaβ do
8:     把 β\betaβ 压入栈 S\mathcal{S}S
9:   end for
10:   令 X←[X⊤,xt]⊤\mathbf{X} \leftarrow [\mathbf{X}^\top, \mathbf{x}_t]^\topX←[X⊤,xt​]⊤
11:   令 t←t+1t \leftarrow t + 1t←t+1
12: end while

We note the explicit connection between the process in Algorithm 1 and parsing algorithms for pushdown automata. A pushdown automaton is a finite state machine which has access to a single stack for long-term storage, and are equivalent to context-free grammars in the sense that every CFG can be converted into a pushdown automaton, and vice-versa (Hopcroft et al., 2006). The decoding algorithm performs the sequence of actions taken by a nondeterministic pushdown automaton at each stage of a parsing algorithm; the nondeterminism is resolved by sampling according to the probabilities in the emitted logit vector.

我们指出,算法 1 中的过程和下推自动机的解析算法有明确对应。下推自动机是一种可以使用单个栈做长期存储的有限状态机,它和上下文无关文法等价:每个 CFG 都可以转换成下推自动机,反之亦然(Hopcroft et al., 2006)。解码算法执行的,正是非确定性下推自动机在解析算法各阶段所采取的动作序列;其中的非确定性,则按发出的 logit 向量中的概率抽样来消解。

Contrasting the character VAE.

和字符级 VAE 的对比。

Notice that the key difference between this grammar VAE decoder and a character-based VAE decoder is that at every point in the generated sequence, the character VAE can sample any possible character. There is no stack or masking operation. The grammar VAE however is constrained to select syntactically-valid sequences.

这个语法 VAE 解码器和基于字符的 VAE 解码器,关键差别在于:在生成序列的每一步,字符级 VAE 都可以抽任何可能的字符,既没有栈,也没有掩码操作。语法 VAE 则被约束为只能选择句法合法的序列。

Syntactic vs. semantic validity.

句法合法与语义合法。

It is important to note that the grammar encodes syntactically valid molecules but not necessarily semantically valid molecules. This is mainly because of three reasons. First, certain molecules produced by the grammar may be very unstable molecules or not chemically-valid (for instance an oxygen atom cannot bond to 3 other atoms as it only has 2 free electrons for bonding, although it would be possible to generate this in a molecule from the grammar). Second, the SMILES language has non-context free aspects, e.g. a ringbond must be opened and closed by the same digit, starting with ‘1’ (as is the case for benzene ‘c1ccccc1’). The particular challenge for matching digits, in contrast to matching grouping symbols such as parentheses, is that they do not compose in a nested manner; for example, ‘C12(CCCCC1)CCCCC2’ is a valid molecule. Keeping track of which digit to use for each ringbond is not context-free. Third, we note that the GVAE can output an undetermined sequence if there are still non-terminal symbols on the stack after processing all Tmax⁡T_{\max}Tmax​ logit vectors. While this could be fixed by a procedure that converts these non-terminals to terminals, for simplicity we mark these sequences as invalid.

需要强调的是,文法保证的是句法上合法的分子,并不一定在语义或化学上也合法。主要有三个原因。第一,文法生成的某些分子可能极不稳定,或在化学上不成立(例如氧原子只有 2 个可用于成键的自由电子,不能和 3 个其他原子成键,但文法仍然可能生成这样的分子)。第二,SMILES 语言有不是上下文无关的地方,例如环键必须用同一个数字打开和关闭,并从 ‘1’ 起计(苯的 ‘c1ccccc1’ 就是这样)。和括号这类分组符号不同,这些数字并不是嵌套组合的;例如 ‘C12(CCCCC1)CCCCC2’ 是一个合法分子。要跟踪每个环键该用哪个数字,并不是上下文无关的。第三,如果处理完全部 Tmax⁡T_{\max}Tmax​ 个 logit 向量后栈上还有非终结符,GVAE 可能输出未完成的序列。这本来可以用把这些非终结符改写成终结符的手续来补救,为简单起见,我们把这类序列标为无效。

3.2. Training

3.2. 训练

During training, each input SMILES encoded as a sequence of 1-hot vectors X∈{0,1}Tmax⁡×K\mathbf{X} \in \{0, 1\}^{T_{\max} \times K}X∈{0,1}Tmax​×K, also defines a sequence of Tmax⁡T_{\max}Tmax​ mask vectors. Each mask at timestep t=1,…,Tmax⁡t = 1, \ldots, T_{\max}t=1,…,Tmax​ is selected by the left-hand side of the production rule indicated in the 1-hot vector xt\mathbf{x}_txt​. Given these masks we can compute the decoder’s mapping

训练时,每个输入 SMILES 都被编成 one-hot 向量序列 X∈{0,1}Tmax⁡×K\mathbf{X} \in \{0, 1\}^{T_{\max} \times K}X∈{0,1}Tmax​×K,同时也就定义了 Tmax⁡T_{\max}Tmax​ 个掩码向量。第 t=1,…,Tmax⁡t = 1, \ldots, T_{\max}t=1,…,Tmax​ 步的掩码,由 one-hot 向量 xt\mathbf{x}_txt​ 所指示的那条产生式的左部决定。有了这些掩码,就可以计算解码器的映射

p(X∣z)=∏t=1T(X)p(xt∣z,x1:(t−1)),(3)p(\mathbf{X}|\mathbf{z}) = \prod_{t=1}^{T(\mathbf{X})} p(\mathbf{x}_t|\mathbf{z}, \mathbf{x}_{1:(t-1)}), \tag{3}p(X∣z)=t=1∏T(X)​p(xt​∣z,x1:(t−1)​),(3)

with the individual probabilities at each timestep defined as in Eq. (2). We pad any remaining timesteps after T(X)T(\mathbf{X})T(X) up to Tmax⁡T_{\max}Tmax​ with a ‘no-op’ rule, a one-hot vector indicating the parse tree is complete and no actions are to be taken.

各步的概率按式 (2) 定义。T(X)T(\mathbf{X})T(X) 之后剩下的时间步,用一条 “no-op” 规则填充到 Tmax⁡T_{\max}Tmax​:这是一个表示解析树已经完成、不再采取动作的 one-hot 向量。

In all our experiments, q(z∣X)q(\mathbf{z}|\mathbf{X})q(z∣X) is a Gaussian distribution whose mean and variance parameters are the output of the encoder network, with an isotropic Gaussian prior p(z)=N(0,I)p(\mathbf{z}) = \mathcal{N}(0, \mathbf{I})p(z)=N(0,I). At training time, we sample a value of z\mathbf{z}z from q(z∣X)q(\mathbf{z}|\mathbf{X})q(z∣X) to compute the ELBO

在我们的全部实验里,q(z∣X)q(\mathbf{z}|\mathbf{X})q(z∣X) 是高斯分布,均值和方差由编码器网络输出,先验则是各向同性高斯 p(z)=N(0,I)p(\mathbf{z}) = \mathcal{N}(0, \mathbf{I})p(z)=N(0,I)。训练时,我们从 q(z∣X)q(\mathbf{z}|\mathbf{X})q(z∣X) 中抽取一个 z\mathbf{z}z 来计算 ELBO

L(ϕ,θ;X)=Eqϕ(z∣X)[log⁡pθ(X,z)−log⁡qϕ(z∣X)].(4)\mathcal{L}(\phi, \theta; \mathbf{X}) = \mathbb{E}_{q_\phi(\mathbf{z}|\mathbf{X})}[\log p_\theta(\mathbf{X}, \mathbf{z}) - \log q_\phi(\mathbf{z}|\mathbf{X})]. \tag{4}L(ϕ,θ;X)=Eqϕ​(z∣X)​[logpθ​(X,z)−logqϕ​(z∣X)].(4)

Following Kingma & Welling (2014), we apply a non-centered parameterization on the encoding Gaussian distribution and optimize Eq. (4) using gradient descent, learning encoder and decoder neural network parameters ϕ\phiϕ and θ\thetaθ. Algorithm 2 summarizes the training procedure.

我们沿用 Kingma & Welling (2014),对编码高斯分布采用非中心参数化,并用梯度下降优化式 (4),同时学习编码器和解码器神经网络的参数 ϕ\phiϕ 和 θ\thetaθ。算法 2 概括了训练过程。

Algorithm 2 Training the Grammar VAE

Input: Dataset {X(i)}i=1N\{\mathbf{X}^{(i)}\}_{i=1}^{N}{X(i)}i=1N​

Output: Trained VAE model pθ(X∣z)p_\theta(\mathbf{X}|\mathbf{z})pθ​(X∣z), qϕ(z∣X)q_\phi(\mathbf{z}|\mathbf{X})qϕ​(z∣X)

1: while VAE not converged do
2:   Select element: X∈{X(i)}i=1N\mathbf{X} \in \{\mathbf{X}^{(i)}\}_{i=1}^{N}X∈{X(i)}i=1N​ (or minibatch)
3:   Encode: z∼qϕ(z∣X)\mathbf{z} \sim q_\phi(\mathbf{z}|\mathbf{X})z∼qϕ​(z∣X)
4:   Decode: given z\mathbf{z}z, compute logits F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K
5:   for ttt in [1,…,Tmax⁡][1, \ldots, T_{\max}][1,…,Tmax​] do
6:     Compute pθ(xt∣z)p_\theta(\mathbf{x}_t|\mathbf{z})pθ​(xt​∣z) via Eq. (2), with mask mxt\mathbf{m}_{\mathbf{x}_t}mxt​​ and logits ft\mathbf{f}_tft​
7:   end for
8:   Update θ,ϕ\theta, \phiθ,ϕ using estimates pθ(X∣z)p_\theta(\mathbf{X}|\mathbf{z})pθ​(X∣z), qϕ(z∣X)q_\phi(\mathbf{z}|\mathbf{X})qϕ​(z∣X), via gradient descent on the ELBO in Eq. (4)
9: end while

算法 2 训练语法 VAE

输入: 数据集 {X(i)}i=1N\{\mathbf{X}^{(i)}\}_{i=1}^{N}{X(i)}i=1N​

输出: 训练好的 VAE 模型 pθ(X∣z)p_\theta(\mathbf{X}|\mathbf{z})pθ​(X∣z),qϕ(z∣X)q_\phi(\mathbf{z}|\mathbf{X})qϕ​(z∣X)

1: while VAE 尚未收敛 do
2:   选取样本:X∈{X(i)}i=1N\mathbf{X} \in \{\mathbf{X}^{(i)}\}_{i=1}^{N}X∈{X(i)}i=1N​(或一个小批量)
3:   编码:z∼qϕ(z∣X)\mathbf{z} \sim q_\phi(\mathbf{z}|\mathbf{X})z∼qϕ​(z∣X)
4:   解码:给定 z\mathbf{z}z,计算 logit F∈RTmax⁡×K\mathbf{F} \in \mathbb{R}^{T_{\max} \times K}F∈RTmax​×K
5:   for ttt 取遍 [1,…,Tmax⁡][1, \ldots, T_{\max}][1,…,Tmax​] do
6:     按式 (2),用掩码 mxt\mathbf{m}_{\mathbf{x}_t}mxt​​ 和 logit ft\mathbf{f}_tft​ 计算 pθ(xt∣z)p_\theta(\mathbf{x}_t|\mathbf{z})pθ​(xt​∣z)
7:   end for
8:   用估计量 pθ(X∣z)p_\theta(\mathbf{X}|\mathbf{z})pθ​(X∣z)、qϕ(z∣X)q_\phi(\mathbf{z}|\mathbf{X})qϕ​(z∣X),对式 (4) 中的 ELBO 做梯度下降,更新 θ,ϕ\theta, \phiθ,ϕ
9: end while

4. Experiments

4. 实验

We show the usefulness of our proposed grammar variational autoencoder (GVAE)² on two sequence optimization problems: 1) searching for an arithmetic expression that best fits a dataset and 2) finding new drug molecules. We begin by showing the latent space of the GVAE and a character variational autoencoder (CVAE), similar to that of Gómez-Bombarelli et al. (2016b)³, on each of the problems. We demonstrate that the GVAE learns a smooth, meaningful latent space for arithmetic equations and molecules. Given this we perform optimization in this latent space using Bayesian optimization, inspired by the technique of Gómez-Bombarelli et al. (2016b). We demonstrate that the GVAE improves upon a previous character variational autoencoder, by selecting an arithmetic expression that matches the data nearly perfectly, and by finding novel molecules with better drug properties.

我们在两个序列优化问题上展示所提出的语法变分自编码器(GVAE)² 的用处:一是搜索最能拟合一组数据的算术表达式,二是寻找新的药物分子。我们先在这两类问题上展示 GVAE 以及一个与 Gómez-Bombarelli et al. (2016b)³ 类似的字符变分自编码器(CVAE)的潜空间,说明 GVAE 能为算术等式和分子学出平滑、有意义的潜空间。随后,我们借鉴 Gómez-Bombarelli et al. (2016b) 的做法,在这个潜空间里做贝叶斯优化。结果表明,GVAE 优于此前的字符变分自编码器:它选出的算术表达式几乎完美拟合数据,也能找到药物性质更好的新分子。

² Code available at: https://github.com/mkusner/grammarVAE

² 代码见:https://github.com/mkusner/grammarVAE

³ https://github.com/maxhodak/keras-molecules

Character VAE Grammar VAE
3*x+exp(3)+exp(1) 3*x+exp(3)+exp(1)
2*2+exp(3)+exp(1) 3*x+exp(3)+exp(1)
3*1+exp(3)+exp(2) 3*x+exp(x)+exp(1/2)
2*1+exp3)+exp(2) 2*x+exp(x)+exp(1/2)
23+(x)+exp(x3) 2x+(x)+exp(1x)
2x+(2)+exp(x3) 2x+(x)+exp(xx)
2x+(1)+exp(xx) 2x+(1)+exp(xx)
3*x+exp(1)+(x+3) 3*x+exp(1)+(x+3)
3x+exp(3)+(x3) 3*x+exp(1)+(x+3)
31+exp(3)+(21) 2*3+exp(x)+(x)
3x+exp(3)+(21) 2*3+x+(x+3)
21+exp(3)+(x2) 2*3+x+(x/3)
2*x+exp3)+xx(3) 22+3+(x3)
22+3+exp(x3) 22+3+exp(x3)
x+1+exp(1)+sin(1*2) x+1+exp(1)+sin(1*2)
x+1+exp(1)+sin(1*2) x+1+exp(1)+sin(1*2)
1+3+exp(x)+(i*1) x/1+exp(x)+sin(x*2)
3+1+exp(2)+(1*1) x/x+sin(x)+exp(x*2)
x+2+exp(x)+(2*3) 3x+sin(x)+(x3)
x3+exp(3)+(32) 3x+sin(3)+(33)
33+sin(3)+(33) 33+sin(3)+(33)
3x+sin(2)+(xx) 3x+sin(2)+(xx)
x1+exp(x)+ex3) 3x+sin(2)+(xx)
x2+exp(x)+exx) 3x+sin(2)+(3x)
x2+exp(x)+(x1) 3x+exp(2)+(33)
x3+exp(x)+(x3) 3x+exp(2)+(33)
x1+exp(x)+(22) 3x+exp(2)+(22)
3x+exp(2)+(22) 3x+exp(2)+(22)

Table 1. Linear interpolation between two equations (in bold, at top and bottom of each cell). The character VAE often passes through intermediate strings which do not decode to a valid equation (shown in red). The grammar VAE makes more fine-grained perturbations at each stage.

Character VAE Grammar VAE
3*x+exp(3)+exp(1) 3*x+exp(3)+exp(1)
2*2+exp(3)+exp(1) 3*x+exp(3)+exp(1)
3*1+exp(3)+exp(2) 3*x+exp(x)+exp(1/2)
2*1+exp3)+exp(2) 2*x+exp(x)+exp(1/2)
23+(x)+exp(x3) 2x+(x)+exp(1x)
2x+(2)+exp(x3) 2x+(x)+exp(xx)
2x+(1)+exp(xx) 2x+(1)+exp(xx)
3*x+exp(1)+(x+3) 3*x+exp(1)+(x+3)
3x+exp(3)+(x3) 3*x+exp(1)+(x+3)
31+exp(3)+(21) 2*3+exp(x)+(x)
3x+exp(3)+(21) 2*3+x+(x+3)
21+exp(3)+(x2) 2*3+x+(x/3)
2*x+exp3)+xx(3) 22+3+(x3)
22+3+exp(x3) 22+3+exp(x3)
x+1+exp(1)+sin(1*2) x+1+exp(1)+sin(1*2)
x+1+exp(1)+sin(1*2) x+1+exp(1)+sin(1*2)
1+3+exp(x)+(i*1) x/1+exp(x)+sin(x*2)
3+1+exp(2)+(1*1) x/x+sin(x)+exp(x*2)
x+2+exp(x)+(2*3) 3x+sin(x)+(x3)
x3+exp(3)+(32) 3x+sin(3)+(33)
33+sin(3)+(33) 33+sin(3)+(33)
3x+sin(2)+(xx) 3x+sin(2)+(xx)
x1+exp(x)+ex3) 3x+sin(2)+(xx)
x2+exp(x)+exx) 3x+sin(2)+(3x)
x2+exp(x)+(x1) 3x+exp(2)+(33)
x3+exp(x)+(x3) 3x+exp(2)+(33)
x1+exp(x)+(22) 3x+exp(2)+(22)
3x+exp(2)+(22) 3x+exp(2)+(22)

表 1. 在两个等式之间做线性插值(每个单元格顶端和底端的粗体式子是两端)。字符级 VAE 常常经过不能解码成合法等式的中间字符串(原文以红色标出)。语法 VAE 在每一步做出的扰动更细。

4.1. Problems

4.1. 问题

We describe in detail the two sequence optimization problems we seek to solve. The first consists in optimizing the fit of an arithmetic expression. We are given a set of 100,000 randomly generated univariate arithmetic expressions from the following grammar:

下面详细说明我们要解决的两个序列优化问题。第一个是优化算术表达式对数据的拟合。我们有一组 100,000 条按下面文法随机生成的一元算术表达式:

S→S ’+’ T∣S ’*’ T∣S ’/’ T∣TT→’(’ S ’)’∣’sin(’ S ’)’∣’exp(’ S ’)’T→’x’∣’1’∣’2’∣’3’\begin{aligned} S &\to S\ \texttt{'+'}\ T \mid S\ \texttt{'*'}\ T \mid S\ \texttt{'/'}\ T \mid T \\ T &\to \texttt{'('}\ S\ \texttt{')'} \mid \texttt{'sin('}\ S\ \texttt{')'} \mid \texttt{'exp('}\ S\ \texttt{')'} \\ T &\to \texttt{'x'} \mid \texttt{'1'} \mid \texttt{'2'} \mid \texttt{'3'} \end{aligned}STT​→S ’+’ T∣S ’*’ T∣S ’/’ T∣T→’(’ S ’)’∣’sin(’ S ’)’∣’exp(’ S ’)’→’x’∣’1’∣’2’∣’3’​

where S and T are non-terminals and the symbol | separates the possible production rules generated from each non-terminal. By parsing this grammar we can randomly generate strings of univariate arithmetic equations (functions of xxx) such as the following: sin⁡(2)\sin(2)sin(2), x/(3+1)x/(3+1)x/(3+1), 2+x+sin⁡(1/2)2+x+\sin(1/2)2+x+sin(1/2), and x/2∗exp⁡(x)/exp⁡(2∗x)x/2 * \exp(x)/\exp(2*x)x/2∗exp(x)/exp(2∗x). We limit the length of every selected string to have at most 15 production rules. Given this dataset we train both the CVAE and GVAE to learn a latent space of arithmetic expressions. We propose to perform optimization in this latent space of expressions to find an expression that best fits a fixed dataset. A common measure of best fit is the test MSE between the predictions made by a selected expression and the true data. In the generated expressions, the presence of exponential functions can result in very large MSE values. For this reason, we use as target variable log⁡(1+MSE)\log(1+\mathrm{MSE})log(1+MSE) instead of MSE.

其中 S 和 T 是非终结符,符号 | 隔开同一个非终结符可以写出的各条产生式。解析这套文法,就可以随机生成一元算术等式(也就是 xxx 的函数),例如:sin⁡(2)\sin(2)sin(2),x/(3+1)x/(3+1)x/(3+1),2+x+sin⁡(1/2)2+x+\sin(1/2)2+x+sin(1/2),以及 x/2∗exp⁡(x)/exp⁡(2∗x)x/2 * \exp(x)/\exp(2*x)x/2∗exp(x)/exp(2∗x)。我们把每条入选字符串的长度限制为最多 15 条产生式。有了这个数据集,我们同时训练 CVAE 和 GVAE,学习算术表达式的潜空间,并打算在这个潜空间里做优化,找出最能拟合一组固定数据的表达式。常用的拟合度量,是所选表达式的预测与真实数据之间的检验均方误差(MSE)。生成的表达式里若出现指数函数,MSE 可能会非常大。因此我们把目标变量改成 log⁡(1+MSE)\log(1+\mathrm{MSE})log(1+MSE),而不直接用 MSE。

For the second optimization problem, we follow (Gómez-Bombarelli et al., 2016b) and optimize the drug properties of molecules. Our goal is to maximize the water-octanol partition coefficient (logP), an important metric in drug design that characterizes the drug-likeness of a molecule. As in Gómez-Bombarelli et al. (2016b) we consider a penalized logP score that takes into account other molecular properties such as ring size and synthetic accessibility (Ertl & Schuffenhauer, 2009). The training data for the CVAE and GVAE models are 250,000 SMILES strings (Weininger, 1988) extracted at random from the ZINC database by Gómez-Bombarelli et al. (2016b). We describe the context-free grammar for SMILES strings that we use to train our GVAE in the supplementary material.

第二个优化问题,我们沿用 Gómez-Bombarelli et al. (2016b),去优化分子的药物性质。目标是最大化水-辛醇分配系数(logP),这是药物设计里刻画类药性的一项重要指标。和他们一样,我们考虑一种带惩罚的 logP 分数,把环大小和合成可及性等其他分子性质也计算进去(Ertl & Schuffenhauer, 2009)。CVAE 和 GVAE 的训练数据,是 Gómez-Bombarelli et al. (2016b) 从 ZINC 数据库中随机抽出的 250,000 条 SMILES 串(Weininger, 1988)。我们用来训练 GVAE 的 SMILES 上下文无关文法写在补充材料里。

4.2. Visualizing the latent space

4.2. 潜空间的可视化

Arithmetic expressions.

算术表达式。

To qualitatively evaluate the smoothness of the VAE embeddings for arithmetic expressions, we attempt interpolating between two arithmetic expressions, as in Bowman et al. (2016). This is done by encoding two equations and then performing linear interpolation in the latent space. Results comparing the character and grammar VAEs are shown in Table 1. Although the character VAE smoothly interpolates between the text representation of equations, it passes through intermediate points which do not decode to valid equations. In contrast, the grammar VAE also provides smooth interpolation and produces valid equations for any location in the latent space. A further exploration of a 2-dimensional latent space is shown in the appendix.

为了定性评估算术表达式 VAE 嵌入的平滑程度,我们像 Bowman et al. (2016) 那样,尝试在两个算术表达式之间做插值:先编码两个等式,再在潜空间里做线性插值。字符级 VAE 和语法 VAE 的对比见表 1。字符级 VAE 虽然在等式的文本表示之间插得比较平滑,但会经过解不出合法等式的中间点。语法 VAE 同样能平滑插值,而且潜空间中任意位置都能解出合法等式。对二维潜空间的进一步考察放在附录里。

Molecules.

分子。

We are interested if the GVAE produces a coherent latent space of molecules. To assess this we begin by encoding a molecule. We then generate 2 random orthogonal unit vectors in latent space (scaled down to only search the neighborhood of the molecules). Moving in combinations of these directions defines a grid and at each point in the grid we decode the latent vector 1000 times. We select the molecule that appears most often as the representative molecule. Figure 3 shows this latent space search surrounding two different molecules. Compare this to Figures 13-15 in Gómez-Bombarelli et al. (2016b). We note that in each plot of the GVAE the latent space is very smooth, in many cases moving from one grid point to another will only change a single atom in a molecule. In the CVAE (Gómez-Bombarelli et al., 2016b) we do not observe such fine-grained smoothness.

我们还关心 GVAE 是否能给出连贯的分子潜空间。评估时,先编码一个分子,再在潜空间里生成 2 个随机的正交单位向量(并缩小尺度,只搜索该分子的邻域)。沿这两个方向的组合移动,就定义出一张网格;在每个网格点上,把潜向量解码 1000 次,取出现次数最多的分子作为代表。图 3 给出了围绕两个不同分子的这种潜空间搜索。可以和 Gómez-Bombarelli et al. (2016b) 的图 13–15 对照。我们看到,GVAE 的每张图里潜空间都非常平滑,很多时候从一个网格点走到下一个,分子里往往只改动一个原子。在 CVAE(Gómez-Bombarelli et al., 2016b)里,我们没有看到这样细粒度的平滑。

在 GVAE 的 56 维潜空间中从中心分子出发做邻域搜索

Figure 3. Searching the 56-dimensional latent space of the GVAE, starting at the molecule in the center.

图 3. 在 GVAE 的 56 维潜空间中搜索,从位于中心的分子出发。

4.3. Bayesian optimization

4.3. 贝叶斯优化

We now perform a series of experiments using the autoencoders to produce novel sequences with improved properties. For this, we follow the approach proposed by Gómez-Bombarelli et al. (2016b) and after training the GVAE, we train an additional model to predict properties of sequences from their latent representation. To propose promising new sequences, we can start from the latent vector of an encoded sequence and then use the output of this predictor (including its gradient) to move in the latent space direction most likely to improve the property. The resulting new latent points can then be decoded into corresponding sequences.

接下来我们用自编码器做一系列实验,生成性质更好的新序列。做法沿用 Gómez-Bombarelli et al. (2016b):在训练好 GVAE 之后,再另训一个模型,从潜表示预测序列的性质。要提出有希望的新序列,可以从已编码序列的潜向量出发,再利用这个预测器的输出(包括其梯度),沿最可能改善该性质的方向在潜空间中移动。得到的新潜点再解码成对应的序列。

In practice, measuring the property of each new sequence could be an expensive process. For example, the sequence could represent an organic photovoltaic molecule and the property could be the result of an expensive quantum mechanical simulation used to estimate the molecule’s power-conversion efficiency (Hachmann et al., 2011). The sequence could also represent a program or expression which may be computationally expensive to evaluate. Therefore, ideally, we would like the optimization process to perform only a reduced number of property evaluations. For this, we use Bayesian optimization methods, which choose the next point to evaluate by maximizing an acquisition function that quantifies the benefit of evaluating the property at a particular location (Shahriari et al., 2016).

实际中,测量每条新序列的性质可能代价很高。例如,序列可以表示有机光伏分子,性质可以是一次昂贵的量子力学模拟结果,用来估计分子的光电转换效率(Hachmann et al., 2011)。序列也可以表示一段程序或表达式,求值同样可能很费计算。因此,理想情况下,优化过程只做较少次数的性质评估。为此我们使用贝叶斯优化:下一步评估哪个点,由最大化采集函数决定,该函数度量在某一位置评估性质的收益(Shahriari et al., 2016)。

After training the GVAE, we obtain a latent feature vector for each sequence in the training data, given by the mean of the variational encoding distributions. We use these vectors and their corresponding property estimates to train a sparse Gaussian process (SGP) model with 500 inducing points (Snelson & Ghahramani, 2005), which is used to make predictions for the properties of new points in latent space. After training the SGP, we then perform 5 iterations of batch Bayesian optimization using the expected improvement (EI) heuristic (Jones et al., 1998). On each iteration, we select a batch of 50 latent vectors by sequentially maximizing the EI acquisition function. We use the Kriging Believer Algorithm to account for pending evaluations in the batch selection process (Cressie, 1990). That is, after selecting each new data point in the batch, we add that data point as a new inducing point in the sparse GP model with associated target variable equal to the mean of the GP predictive distribution at that point.

训练完 GVAE 后,我们取变分编码分布的均值,为训练数据中的每条序列得到一个潜特征向量。用这些向量和对应的性质估计,训练一个带 500 个诱导点的稀疏高斯过程(SGP)模型(Snelson & Ghahramani, 2005),用来预测潜空间中新点的性质。SGP 训练完成后,再用期望改进(EI)启发式做 5 轮批量贝叶斯优化(Jones et al., 1998)。每一轮里,我们按顺序最大化 EI 采集函数,选出一批 50 个潜向量。批量选择时用 Kriging Believer 算法处理尚未完成的评估(Cressie, 1990)。也就是说,每在批次中选中一个新数据点,就把它作为新的诱导点加入稀疏 GP,对应的目标变量取该点处 GP 预测分布的均值。

Once a new batch of 50 latent vectors is selected, each point in the batch is transformed into its corresponding sequence using the decoder network in the GVAE. The properties of the newly generated sequences are then computed and the resulting data is added to the training set before retraining the SGP and starting the next BO iteration. Note that some of the new sequences will be invalid and consequently, it will not be possible to obtain their corresponding property estimate. In this case we fix the property to be equal to the worst value observed in the original training data.

选出一批 50 个新潜向量后,用 GVAE 的解码网络把批次中的每个点变成对应序列。再计算这些新生成序列的性质,把得到的数据加入训练集,然后重新训练 SGP,开始下一轮贝叶斯优化。需要说明的是,部分新序列会不合法,因而无法得到对应的性质估计。这时我们把该性质固定为原始训练数据中观测到的最差值。

Arithmetic expressions.

算术表达式。

Our goal is to see if we can find an arithmetic expression that best fits a fixed dataset. Specifically, we generate this dataset by selecting 1000 input values, xxx, that are linearly-spaced between −10-10−10 and 101010. We then pass these through our true function 1/3+x+sin⁡(x∗x)1/3 + x + \sin(x * x)1/3+x+sin(x∗x) to generate the true target observations. We use Bayesian optimization (BO) as described above search for this equation. We run BO for 5 iterations and average across 10 repetitions of the process. Table 2 (rows 1 & 2) shows the results obtained. The third column in the table reports the fraction of arithmetic sequences found by BO that are valid. The GVAE nearly always finds valid sequences. The only cases in which it does not is when there are still non-terminals on the stack of the decoder upon reaching the maximum number of time-steps Tmax⁡T_{\max}Tmax​, however this is rare. Additionally, the GVAE finds squences with better scores on average when compared with the CVAE.

我们想看能否找到最拟合某一固定数据集的算术表达式。具体做法是:选取在 −10-10−10 与 101010 之间均匀间隔的 1000 个输入值 xxx,再送入真实函数 1/3+x+sin⁡(x∗x)1/3 + x + \sin(x * x)1/3+x+sin(x∗x),得到真实目标观测。我们用上文所述的贝叶斯优化(BO)来搜索这个等式。BO 运行 5 轮,并对该过程的 10 次重复取平均。表 2(第 1、2 行)给出结果。表中第三列是 BO 找到的算术序列里合法序列的比例。GVAE 几乎总能找到合法序列;唯一找不到的情形,是解码器在达到最大时间步 Tmax⁡T_{\max}Tmax​ 时栈上仍有非终结符,不过这种情况很少。此外,与 CVAE 相比,GVAE 找到的序列平均分数也更好。

Problem Method Frac. valid Avg. score
Expressions GVAE 0.99±0.01 3.47 ±0.24
Expressions CVAE 0.86±0.06 4.75±0.25
Molecules GVAE 0.31±0.07 -9.57 ±1.77
Molecules CVAE 0.17±0.05 -27.42±8.12

Table 2. Results finding best expression and molecule

Problem Method Frac. valid Avg. score
Expressions GVAE 0.99±0.01 3.47 ±0.24
Expressions CVAE 0.86±0.06 4.75±0.25
Molecules GVAE 0.31±0.07 -9.57 ±1.77
Molecules CVAE 0.17±0.05 -27.42±8.12

表 2. 寻找最佳表达式和分子的结果

Method # Expression Score
GVAE 1 x/1+sin⁡(3)+sin⁡(x∗x)x/1 + \sin(3) + \sin(x * x)x/1+sin(3)+sin(x∗x) 0.04
GVAE 2 1/2+(x)+sin⁡(x∗x)1/2 + (x) + \sin(x * x)1/2+(x)+sin(x∗x) 0.10
GVAE 3 x/x+(x)+sin⁡(x∗x)x/x + (x) + \sin(x * x)x/x+(x)+sin(x∗x) 0.37
CVAE 1 x∗1+sin⁡(3)+sin⁡(3/1)x * 1 + \sin(3) + \sin(3/1)x∗1+sin(3)+sin(3/1) 0.39
CVAE 2 x∗1+sin⁡(1)+sin⁡(2∗3)x * 1 + \sin(1) + \sin(2 * 3)x∗1+sin(1)+sin(2∗3) 0.40
CVAE 3 x+1+sin⁡(3)+sin⁡(3+1)x + 1 + \sin(3) + \sin(3 + 1)x+1+sin(3)+sin(3+1) 0.40

Table 3. Best expressions found by each method

Method # Expression Score
GVAE 1 x/1+sin⁡(3)+sin⁡(x∗x)x/1 + \sin(3) + \sin(x * x)x/1+sin(3)+sin(x∗x) 0.04
GVAE 2 1/2+(x)+sin⁡(x∗x)1/2 + (x) + \sin(x * x)1/2+(x)+sin(x∗x) 0.10
GVAE 3 x/x+(x)+sin⁡(x∗x)x/x + (x) + \sin(x * x)x/x+(x)+sin(x∗x) 0.37
CVAE 1 x∗1+sin⁡(3)+sin⁡(3/1)x * 1 + \sin(3) + \sin(3/1)x∗1+sin(3)+sin(3/1) 0.39
CVAE 2 x∗1+sin⁡(1)+sin⁡(2∗3)x * 1 + \sin(1) + \sin(2 * 3)x∗1+sin(1)+sin(2∗3) 0.40
CVAE 3 x+1+sin⁡(3)+sin⁡(3+1)x + 1 + \sin(3) + \sin(3 + 1)x+1+sin(3)+sin(3+1) 0.40

表 3. 各方法找到的最佳表达式

GVAE 与 CVAE 找到的最佳表达式曲线对比

Figure 4. Plot of best expressions found by each method

图 4. 各方法找到的最佳表达式曲线。

Table 3 shows the top 3 expressions found by GVAE and CVAE during the BO search, together with their associated score values. Figure 4 shows how the best expression found by GVAE and CVAE compare to the true function. We note that the CVAE has failed to find the sinusoidal portion of the true expression, while the difference between the GVAE expression and the true function is negligible.

表 3 给出 GVAE 与 CVAE 在贝叶斯优化搜索中找到的前 3 个表达式及其分数。图 4 把两种方法找到的最佳表达式与真实函数加以对比。可以看到,CVAE 没有找回真实表达式中的正弦部分,而 GVAE 的表达式与真实函数之间的差别可以忽略。

Molecules.

分子。

We now consider the problem of finding new drug-like molecules. We perform 5 iterations of BO, and average results across 10 trials. Table 2 (rows 3 & 4) shows the overall BO results. In this problem, the GVAE produces about twice more valid sequences than the CVAE. The valid sequences produced by the GVAE also result in higher scores on average. The best found SMILES strings by each method and their scores are shown in Table 4; the molecules themselves are plotted in Figure 5.

下面考虑寻找新的类药分子。我们做 5 轮贝叶斯优化,并在 10 次试验上取平均。表 2(第 3、4 行)给出总体结果。在这个问题上,GVAE 产生的合法序列大约是 CVAE 的两倍;这些合法序列的平均分数也更高。各方法找到的最佳 SMILES 及其分数见表 4,分子结构本身画在图 5 中。

GVAE 与 CVAE 找到的最佳分子结构

Figure 5. Plot of best molecules found by each method.

图 5. 各方法找到的最佳分子。

Method # SMILE Score
GVAE 1 CCCc1ccc(I)cc1C1CCC-c1 2.94
GVAE 2 CC(C)CCCCCc1ccc(Cl)nc1 2.89
GVAE 3 CCCc1ccc(Cl)cc1CCCCOC 2.80
CVAE 1 Cc1ccccc1CCCC1CCC1CCc1nncs1 1.98
CVAE 2 Cc1ccccc1CCCC1(COC1)CCc1nnn1 1.42
CVAE 3 CCCCCCCCC(CCCC212CCCnC1COC)c122csss1 1.19

Table 4. Best molecules found by each method

Method # SMILE Score
GVAE 1 CCCc1ccc(I)cc1C1CCC-c1 2.94
GVAE 2 CC(C)CCCCCc1ccc(Cl)nc1 2.89
GVAE 3 CCCc1ccc(Cl)cc1CCCCOC 2.80
CVAE 1 Cc1ccccc1CCCC1CCC1CCc1nncs1 1.98
CVAE 2 Cc1ccccc1CCCC1(COC1)CCc1nnn1 1.42
CVAE 3 CCCCCCCCC(CCCC212CCCnC1COC)c122csss1 1.19

表 4. 各方法找到的最佳分子

4.4. Predictive performance of latent representation

4.4. 潜表示的预测性能

We now perform a series of experiments to evaluate the predictive performance of the latent representations found by each autoencoder. For this, we use the sparse GP model used in the previous Bayesian optimization experiments and look at its predictive performance on a left-out test set with 10% of the data, where the data is formed by the latent representation of the available sequences (these are the inputs to the sparse GP model) and the associated properties of those sequences (these are the outputs in the sparse GP model). Table 5 show the average test RMSE and test log-likelihood for the GVAE and the CVAE across 10 different splits of the data for the expressions and for the molecules. This table shows that the GVAE produces latent features that yield much better predictive performance than those produced by the CVAE.

下面再做一组实验,评估各自编码器学到的潜表示的预测性能。我们沿用上一节贝叶斯优化里的稀疏 GP 模型,在留出 10% 数据的检验集上看它的预测表现;这里的数据由已有序列的潜表示(作为稀疏 GP 的输入)和这些序列对应的性质(作为稀疏 GP 的输出)组成。表 5 给出 GVAE 与 CVAE 在表达式和分子两类数据上、对 10 种不同划分平均后的检验 RMSE 和检验对数似然。从表中可以看到,GVAE 给出的潜特征,预测性能明显好于 CVAE。

Objective Method Expressions Molecules
LL GVAE -1.320±0.001 -1.739 ±0.004
LL CVAE -1.397±0.003 -1.812±0.004
RMSE GVAE 0.884 ±0.002 1.404 ±0.006
RMSE CVAE 0.975±0.004 1.504±0.006

Table 5. Test Log-likelihood (LL) and RMSE for the sparse GP predictions of penalized LogP score from the latent space

Objective Method Expressions Molecules
LL GVAE -1.320±0.001 -1.739 ±0.004
LL CVAE -1.397±0.003 -1.812±0.004
RMSE GVAE 0.884 ±0.002 1.404 ±0.006
RMSE CVAE 0.975±0.004 1.504±0.006

表 5. 用稀疏 GP 从潜空间预测带惩罚的 LogP 分数时的检验对数似然(LL)与 RMSE

5. Related Work

5. 相关工作

Parse trees have been used to learn continuous representations of text in recursive neural network models (Socher et al., 2013; Irsoy & Cardie, 2014; Paulus et al., 2014). These models learn a vector at every non-terminal in the parse tree by recursively combining the vectors of child nodes. Recursive autoencoders learn these representations by minimizing the reconstruction error between true child vectors and those predicted by the parent (Socher et al., 2011a;b). Recently, Allamanis et al. (2016) learn representations for symbolic expressions from their parse trees. Importantly, all of these methods are discriminative and do not learn a generative latent space. Like our decoder, recurrent neural network grammars (Dyer et al., 2016) produce sequences through a linear traversal of the parse tree, but focus on the case where the underlying grammar is unknown and not context-free. Maddison & Tarlow (2014) describe generative models of natural source code based on probabilistic context free grammars and neuro-probabilistic language models. However, these works are not geared towards learning a latent representation of the data.

解析树曾被用在递归神经网络里,学习文本的连续表示(Socher et al., 2013; Irsoy & Cardie, 2014; Paulus et al., 2014)。这类模型在解析树的每个非终结符上学习一个向量,做法是递归地组合子结点的向量。递归自编码器则通过最小化真实子向量与父结点预测出的子向量之间的重构误差来学习这些表示(Socher et al., 2011a;b)。最近,Allamanis et al. (2016) 从解析树学习符号表达式的表示。重要的是,这些方法都是判别式的,并不学习生成式潜空间。和我们的解码器类似,循环神经网络文法(Dyer et al., 2016)也通过线性遍历解析树来生成序列,但关注的是底层文法未知、且并非上下文无关的情形。Maddison & Tarlow (2014) 描述了基于概率上下文无关文法和神经概率语言模型的自然语言源代码生成模型。不过,这些工作的目标并不是学习数据的潜表示。

Learning arithmetic expressions to fit data, often called symbolic regression, are generally based on genetic programming (Willis et al., 1997) or other computationally demanding evolutionary algorithms to propose candidate expressions (Schmidt & Lipson, 2009). Alternatives include running particle MCMC inference to estimate a Bayesian posterior over parse trees (Perov & Wood, 2016).

学习拟合数据的算术表达式通常称为符号回归,一般依靠遗传规划(Willis et al., 1997),或其他计算开销很大的进化算法来提出候选表达式(Schmidt & Lipson, 2009)。另一些做法包括运行粒子 MCMC 推断,估计解析树上的贝叶斯后验(Perov & Wood, 2016)。

In molecular design, searching for new molecules is traditionally done by sifting through large databases of potential molecules and then subjecting them to a virtual screening process (Pyzer-Knapp et al., 2015; Gómez-Bombarelli et al., 2016a). These databases are too large to search via exhaustive enumeration, and require novel stochastic search algorithms tailored to the domain (Virshup et al., 2013; Rupakheti et al., 2015). Segler et al. (2017) fit a recurrent neural network to chemicals represented by SMILES strings, however their goal is more akin to density estimation; they learn a simulator which can sample proposals for novel molecules, but it is not otherwise used as part of an optimization or inference process itself. Our work most closely resembles Gómez-Bombarelli et al. (2016b) for novel molecule synthesis, in that we also learn a latent variable model which admits a continuous representation of the domain. However, both Segler et al. (2017) and Gómez-Bombarelli et al. (2016b) use character-level models for molecules.

在分子设计里,寻找新分子的传统做法是筛过大规模的候选分子数据库,再做虚拟筛选(Pyzer-Knapp et al., 2015; Gómez-Bombarelli et al., 2016a)。这些数据库太大,无法穷举搜索,因此需要针对该领域的新型随机搜索算法(Virshup et al., 2013; Rupakheti et al., 2015)。Segler et al. (2017) 用循环神经网络拟合以 SMILES 表示的化合物,不过他们的目标更接近密度估计:学到的是一个可以抽样新分子提案的模拟器,并不把它本身纳入优化或推断过程。我们的工作与 Gómez-Bombarelli et al. (2016b) 的新分子合成最为接近,因为我们也学习一个能给出该领域连续表示的潜变量模型。不过,Segler et al. (2017) 和 Gómez-Bombarelli et al. (2016b) 对分子用的都是字符级模型。

6. Discussion

6. 讨论

Empirically, it is clear that representing molecules and equations by way of their parse tree generated from a grammar outperforms text-based representations. We believe this approach will be broadly useful for representation learning, inference, and optimization in any domain which can be represented as text in a context-free language.

从实验结果看,用文法生成的解析树来表示分子和等式,明显优于基于文本的表示。我们相信,在任何可以写成上下文无关语言中文本的领域里,这种方法对表示学习、推断和优化都会有较广的用处。

Acknowledgements

致谢

This work was supported by The Alan Turing Institute under the EPSRC grant EP/N510129/1.

本工作由 The Alan Turing Institute 通过 EPSRC 资助 EP/N510129/1 支持。

References

参考文献

Allamanis, Miltiadis, Chanthirasegaran, Pankajan, Kohli, Pushmeet, and Sutton, Charles. Learning continuous semantic representations of symbolic expressions. arXiv preprint arXiv:1611.01423, 2016.

Baker, James K. Trainable grammars for speech recognition. The Journal of the Acoustical Society of America, 65(S1):S132–S132, 1979.

Booth, Taylor L and Thompson, Richard A. Applying probability measures to abstract languages. IEEE transactions on Computers, 100(5):442–450, 1973.

Bowman, Samuel R, Vilnis, Luke, Vinyals, Oriol, Dai, Andrew M, Jozefowicz, Rafal, and Bengio, Samy. Generating sentences from a continuous space. CoNLL 2016, pp. 10, 2016.

Cho, Kyunghyun, Van Merriënboer, Bart, Gulcehre, Caglar, Bahdanau, Dzmitry, Bougares, Fethi, Schwenk, Holger, and Bengio, Yoshua. Learning phrase representations using rnn encoder-decoder for statistical machine translation. arXiv preprint arXiv:1406.1078, 2014.

Cressie, Noel. The origins of kriging. Math. Geol., 22(3):239–252, 1990.

Dyer, Chris, Kuncoro, Adhiguna, Ballesteros, Miguel, and Smith, Noah A. Recurrent neural network grammars. In Proceedings of NAACL-HLT, pp. 199–209, 2016.

Ertl, Peter and Schuffenhauer, Ansgar. Estimation of synthetic accessibility score of drug-like molecules based on molecular complexity and fragment contributions. Journal of cheminformatics, 1(1):8, 2009.

Gatys, Leon A, Ecker, Alexander S, and Bethge, Matthias. A neural algorithm of artistic style. arXiv preprint arXiv:1508.06576, 2015.

Gaunt, Alexander L, Brockschmidt, Marc, Singh, Rishabh, Kushman, Nate, Kohli, Pushmeet, Taylor, Jonathan, and Tarlow, Daniel. Terpret: A probabilistic programming language for program induction. arXiv preprint arXiv:1608.04428, 2016.

Gómez-Bombarelli, Rafael, Aguilera-Iparraguirre, Jorge, Hirzel, Timothy D, Duvenaud, David, Maclaurin, Dougal, Blood-Forsythe, Martin A, Chae, Hyun Sik, et al. Design of efficient molecular organic light-emitting diodes by a high-throughput virtual screening and experimental approach. Nature Materials, 15(10):1120–1127, 2016a.

Gómez-Bombarelli, Rafael, Duvenaud, David, Hernández-Lobato, José Miguel, Aguilera-Iparraguirre, Jorge, Hirzel, Timothy D, Adams, Ryan P, and Aspuru-Guzik, Alán. Automatic chemical design using a data-driven continuous representation of molecules. arXiv preprint arXiv:1610.02415, 2016b.

Hachmann, J., Olivares-Amaya, R., Atahan-Evrenk, S., Amador-Bedolla, C., Sanchez-Carrera, R. S., Gold-Parker, A., Vogt, L., Brockway, A. M., and Aspuru-Guzik, A. The Harvard Clean Energy Project: Large-Scale Computational Screening and Design of Organic Photovoltaics on the World Community Grid. J. Phys. Chem. Lett., 2(17):2241–2251, sep 2011.

Hochreiter, Sepp and Schmidhuber, Jürgen. Long short-term memory. Neural computation, 9(8):1735–1780, 1997.

Hopcroft, John E, Motwani, Rajeev, and Ullman, Jeffrey D. Introduction to Automata theory, languages, and computation. 2006.

Irsoy, Ozan and Cardie, Claire. Deep recursive neural networks for compositionality in language. In NIPS, pp. 2096–2104, 2014.

James, Craig A, Vandermeersch, T, and Dalke, A. Opensmiles specification, 2015.

Jaques, Natasha, Gu, Shixiang, Turner, Richard E, and Eck, Douglas. Tuning recurrent neural networks with reinforcement learning. arXiv preprint arXiv:1611.02796, 2016.

Johnson, Mark, Griffiths, Thomas L, Goldwater, Sharon, et al. Adaptor grammars: A framework for specifying compositional nonparametric bayesian models. Advances in neural information processing systems, 19:641, 2007.

Jones, Donald R, Schonlau, Matthias, and Welch, William J. Efficient global optimization of expensive black-box functions. Journal of Global optimization, 13(4):455–492, 1998.

Kalchbrenner, Nal, Grefenstette, Edward, and Blunsom, Phil. A convolutional neural network for modelling sentences. 2014.

Kernighan, Brian W, Ritchie, Dennis M, and Ejeklint, Per. The C programming language, volume 2. Prentice-Hall Englewood Cliffs, 1988.

Kingma, Diederik P and Welling, Max. Auto-encoding variational Bayes. In Proceedings of the International Conference on Learning Representations (ICLR), 2014.

Kusner, Matt J and Hernández-Lobato, José Miguel. Gans for sequences of discrete elements with the gumbel-softmax distribution. arXiv:1611.04051, 2016.

Maddison, Chris and Tarlow, Daniel. Structured generative models of natural source code. In Proceedings of the 31st International Conference on Machine Learning (ICML), pp. 649–657, 2014.

Paulus, Romain, Socher, Richard, and Manning, Christopher D. Global belief recursive neural networks. In Advances in Neural Information Processing Systems, pp. 2888–2896, 2014.

Perov, Yura and Wood, Frank. Automatic sampler discovery via probabilistic programming and approximate bayesian computation. In International Conference on Artificial General Intelligence, pp. 262–273, 2016.

Pyzer-Knapp, Edward O, Suh, Changwon, Gómez-Bombarelli, Rafael, Aguilera-Iparraguirre, Jorge, and Aspuru-Guzik, Alán. What is high-throughput virtual screening? a perspective from organic materials discovery. Annual Review of Materials Research, 45:195–216, 2015.

Radford, Alec, Metz, Luke, and Chintala, Soumith. Unsupervised representation learning with deep convolutional generative adversarial networks. arXiv preprint arXiv:1511.06434, 2015.

Rezende, Danilo Jimenez, Mohamed, Shakir, and Wierstra, Daan. Stochastic backpropagation and approximate inference in deep generative models. arXiv preprint arXiv:1401.4082, 2014.

Riedel, Sebastian, Bosnjak, Matko, and Rocktäschel, Tim. Programming with a differentiable forth interpreter. CoRR, abs/1605.06640, 2016.

Rupakheti, Chetan, Virshup, Aaron, Yang, Weitao, and Beratan, David N. Strategy to discover diverse optimal molecules in the small molecule universe. Journal of chemical information and modeling, 55(3):529–537, 2015.

Schmidt, Michael and Lipson, Hod. Distilling free-form natural laws from experimental data. Science, 324(5923):81–85, 2009.

Segler, Marwin HS, Kogej, Thierry, Tyrchan, Christian, and Waller, Mark P. Generating focussed molecule libraries for drug discovery with recurrent neural networks. arXiv preprint arXiv:1701.01329, 2017.

Shahriari, Bobak, Swersky, Kevin, Wang, Ziyu, Adams, Ryan P, and de Freitas, Nando. Taking the human out of the loop: A review of bayesian optimization. Proceedings of the IEEE, 104(1):148–175, 2016.

Snelson, Edward and Ghahramani, Zoubin. Sparse Gaussian processes using pseudo-inputs. In NIPS, pp. 1257–1264, 2005.

Socher, Richard, Huang, Eric H, Pennington, Jeffrey, Ng, Andrew Y, and Manning, Christopher D. Dynamic pooling and unfolding recursive autoencoders for paraphrase detection. In NIPS, volume 24, pp. 801–809, 2011a.

Socher, Richard, Pennington, Jeffrey, Huang, Eric H, Ng, Andrew Y, and Manning, Christopher D. Semi-supervised recursive autoencoders for predicting sentiment distributions. In Proceedings of the conference on empirical methods in natural language processing, pp. 151–161. Association for Computational Linguistics, 2011b.

Socher, Richard, Perelygin, Alex, Wu, Jean Y, Chuang, Jason, Manning, Christopher D, Ng, Andrew Y, Potts, Christopher, et al. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the conference on empirical methods in natural language processing (EMNLP), volume 1631, pp. 1642. Citeseer, 2013.

Upchurch, Paul, Gardner, Jacob, Bala, Kavita, Pless, Robert, Snavely, Noah, and Weinberger, Kilian. Deep feature interpolation for image content changes. arXiv preprint arXiv:1611.05507, 2016.

Virshup, Aaron M, Contreras-García, Julia, Wipf, Peter, Yang, Weitao, and Beratan, David N. Stochastic voyages into uncharted chemical space produce a representative library of all possible drug-like compounds. Journal of the American Chemical Society, 135(19):7296–7303, 2013.

Weininger, David. Smiles, a chemical language and information system. 1. introduction to methodology and encoding rules. J. Chem. Inf. Comput. Sci., 28(1):31–36, 1988.

Willis, M-J, Hiden, Hugo G, Marenbach, Peter, McKay, Ben, and Montague, Gary A. Genetic programming: An introduction and survey of applications. In Genetic Algorithms in Engineering Systems, pp. 314–319. IET, 1997.

Zhao, Shengjia, Song, Jiaming, and Ermon, Stefano. Info-vae: Information maximizing variational autoencoders. arXiv preprint arXiv:1706.02262, 2017.