G EO S EQ 2S EQ : I NFORMATION G EOMETRIC S EQUENCE - TO -S EQUENCE N ETWORKS
A BSTRACT
The Fisher information metric is an important foundation of information geometry, wherein it allows us to approximate the local geometry of a probability distribution.
Recurrent neural networks such as the Sequence-to-Sequence (Seq2Seq) networks that have lately been used to yield state-of-the-art performance on speech translation or image captioning have so far ignored the geometry of the latent embedding, that they iteratively learn.
We propose the information geometric
Seq2Seq (GeoSeq2Seq) network which abridges the gap between deep recurrent neural networks and information geometry.
Speciﬁcally, the latent embedding offered by a recurrent network is encoded as a Fisher kernel of a parametric Gaussian Mixture Model, a formalism common in computer vision.
We utilise such a network to predict the shortest routes between two nodes of a graph by learning the adjacency matrix using the GeoSeq2Seq formalism; our results show that for such a problem the probabilistic representation of the latent embedding supersedes the non-probabilistic embedding by 10-15%
I NTRODUCTION
Information geometry situates itself in the intersection of probability theory and differential geometry, wherein it has found utility in understanding the geometry of a wide variety of probability models (Amari & Nagaoka, 2000).
By virtue of Cencov’s characterisation theorem, the metric on such probability manifolds is described by a unique kernel known as the Fisher information metric.
In statistics, the Fisher information is simply the variance of the score function.
In Bayesian statistics, it has found utility in terms of Riemannian Markov Chain Monte Carlo (MCMC) methods (Girolami &
Calderhead, 2011) while for computer vision it has resulted in the Fisher kernel encoding (Perronnin & Dance, 2006).
Practitioners have also used the geometric make-up of feature vectors obtained from a deep convolutional neural network (dCNN) to rank images (Qian et al., 2017) by encoding them using Fisher kernels.
Apart from traditional signal processing methodologies like Kalman ﬁlters or
Hidden Markov Models, recurrent neural networks that have proved to be beneﬁcial for sequential data haven’t quite utilised the geometry of the latent structure they learn.
There are two paths of an intersection of recurrent networks with Riemann geometry.
The ﬁrst lies in using the natural gradient to optimize loss functions of deep neural networks (Pascanu & Bengio, 2013).
This affords invariance to the optimization procedure by breaking the symmetry in parameter space.
The other is utilizing the geometry of the latent space to augment classiﬁcation accuracy.
In this paper, we combine a speciﬁc sort of recurrent network – the Sequence-to-Sequence (Seq2Seq) model – and utilize the Riemann geometry of the embedded space for boosting the performance of the decoder.
We test the algorithm on a combinatorially hard problem called the shortest route problem .
The problem involves a large graph wherein the shortest route between two nodes in the graph are required.
Speciﬁcally, we use a meta-heuristic algorithm (a vanilla A ∗ algorithm) to generate the shortest route between two randomly selected routes.
This then serves as the training set for our
GeoSeq2Seq network.
R ELATED WORKS
Recently, the research direction of combining deep learning with methods from information geometry has proven to be an exciting and a fertile research area.
In particular, natural gradient methods in deep learning have recently been explored to model the second-order curvature information.
For example, Natural Neural Networks (Desjardins et al., 2015) have sped up convergence by adapting their internal representation during training to improve the conditioning of the Fisher information matrix.
On the other hand, it is also possible to approximate the Fisher information matrix, either with a Gaussian graphical model, whose precision matrix can be computed efﬁciently (Grosse &
Salakhudinov, 2015) or by decomposing it as the Kronecker product of small matrices, which capture important curvature information (Grosse & Martens, 2016).
More closely related to the topic of this paper, Fisher vector encodings and deep networks have been combined for image classiﬁcation tasks (Sydorov et al., 2014).
For example, Fisher vector image encoding can be stacked in multiple layers (Simonyan et al., 2013b), showing that convolutional networks and Fisher vector encodings are complementary.
Furthermore, recent work has introduced deep learning on graphs.
For example, Pointer Networks (Vinyals et al., 2015) use a Seq2Seq model to solve the travelling salesman problem, yet it assumes that the entire graph is provided as input to the model.
To the best of our knowledge, there has been very little work on using the Fisher vectors of a recurrent neural encoding, generated from RNNs (recurrent neural networks), LSTMs (Long shortterm memory) and GRUs (Gated recurrent units) based sequence-to-sequence (Seq2Seq) models.
Therefore, the work presented here is complementary to the other lines of work, with the hope to increase the ﬁdelity of these networks to retain the memory of long sequences.
M ETHODS
In this section, we describe the data-sets, the procedure for generating the routes for training/test datasets, and the deployment of information geometric Sequence-to-Sequence networks that forms the novel contribution of this paper.
All of the calculations were performed on a i7-6800K CPU @
3.40GHz workstation with 32 GB RAM and a single nVidia GeForce GTX 1080Ti graphics card.
3. D ATASETS
The graph is based on the road network of Minnesota 1 .
Each node represents the intersections of roads while the edges represent the road that connects the two points of intersection.
Speciﬁcally, the graph we considered has 376 nodes and 455 edges, as we constrained the coordinates of the nodes to be in the range [ − 97 , − 94] for the longitude and [46 , 49] for the latitude, instead of the full extent of the graph, i.e., a longitude of [ − 97 , − 89] and a latitude of [43 , 49] , with a total number of 2, nodes.
3. A LGORITHMS T HE A ∗ META - HEURISTICS
The A ∗ algorithm is a best-ﬁrst search algorithm wherein it searches amongst all of the possible paths that yield the smallest cost.
This cost function is made up of two parts – particularly, each iteration of the algorithm consists of ﬁrst evaluating the distance travelled or time expended from the start node to the current node.
The second part of the cost function is a heuristic that estimates the cost of the cheapest path from the current node to the goal.
Without the heuristic part, this algorithm operationalises the Dijkstra’s algorithm (Dijkstra, 1959).
There are many variants of A ∗ ; in our experiments, we use the vanilla A ∗ with a heuristic based on the Euclidean distance.
Other variants such as Anytime Repairing A ∗ has been shown to produce superior performance (Likhachev et al., 2004).
Paths between two nodes selected uniformly at random are calculated using the A ∗ algorithm.
On an average, the paths are 19 hops long.
The average fan-in/fan-out of a randomly selected node is 2.42.
We increase the combinatorial difﬁculty of the shortest route by not constraining the search to the local fan-out neighbourhood, rather the dimension of the search space is n − 1 with n representing the number of nodes in the graph.
R ECURRENT DEEP NETWORKS
We utilised Sequence-to-Sequence (Seq2Seq, Sutskever et al.
recurrent neural networks for the shortest route path prediction.
Speciﬁcally, we use the following variants:
• An LSTM2RNN, where the encoder is modelled by a long short term memory (LSTM [Equation] Hochreiter & Schmidhuber [Equation]
[Equation]
while the decoder is a vanilla RNN (Goodfellow et al., 2016), i [Equation] e.
[Equation]
followed by a softmax output layer,
i
[Equation]
e.
[Equation]
which gives the probability distribution on the following node, choosing it among the other n − 1 nodes.
• A GRU2RNN, where the encoder is modelled by a gated recurrent unit (GRU, Cho et al.
(2014)), i.e.
[Equation]
while the decoder is again a vanilla RNN with a softmax, as in Equations (2)-(3).
• An LSTM2LSTM, where both the encoder and the decoder are modelled by an LSTM as in Equations (1).
• A GRU2LSTM, where the encoder is a GRU (see Eqn.
and the decoder is an LSTM (see Eqn.
• GeoSeq2Seq , our novel contribution, where the context vector obtained as in one of the previous models is further encoded using either Fisher vectors or vectors of locally aggregated descriptors (VLAD; see Figure 1), as described in the following section
For all networks, the input is represented by the [source, destination] tuple (Figure 1), which is encoded in a context vector ( W ) and subsequently decoded into the ﬁnal sequence to obtain the shortest path connecting the source to the destination.
Moreover, during the test phase, we compute two paths, one from the source to the destination node and the other from the destination to the source node, that forms an intersection to result in the shortest path.
[Figure]
I NFORMATION G EOMETRY
Classical results from information geometry (Cencov’s characterisation theorem; Amari & Nagaoka (2000)) tell us that, for manifolds based on probability measures, a unique Riemannian metric exists – the Fisher information metric.
In statistics, Fisher-information is used to measure the expected value of the observed information.
Whilst the Fisher-information becomes the metric ( g ) for curved probability spaces, the distance between two distributions is provided by the Kullback-Leibler (KL) divergence.
It turns out that if the KL-divergence is viewed as a curve on a curved surface, the
Fisher-information becomes its curvature.
Formally, for a distribution q ( ψ ) parametrised by θ we have,
[Equation]
Fisher encoding We use a Gaussian Mixture Model (GMM) for encoding a probabilistic sequence vocabulary ( W ) on the training dataset.
The context vectors are then represented as Fisher Vectors (FV, Perronnin & Dance (2006))
– derivatives of log-likelihood of the model with respect to its parameters (the score function).
Fisher encoding describes how the distribution of features of an individual context differs from the distribution ﬁtted to the feature of all training sequences.
First, a set of D dimension context vector is extracted from a sequence and denoted as
W = (cid:0) w 1 , ...
w i , ..., w N : w ∈ R D (cid:1) .
A K component GMM with diagonal covariance is generated (Simonyan et al., 2013a; Cimpoi et al., 2015) on the training set with the parameters { Θ = ( ω k , µ k , Σ k ) }
Kk =1 , only the derivatives with respect to the mean { µ k } Kk = and variances { Σ k } Kk =1 are encoded and concatenated to represent a sequence W ( X, Θ) = (cid:16)
[Equation]
, where
[Equation]
For each component k , mean and covariance deviation on each vector dimension j = 1 ,
D are
[Equation]
where q ik is the soft assignment weight of feature w i to the k th Gaussian and deﬁned as
[Equation]
Just as the sequence representation, the dimension of Fisher vector is 2 KD , K is the number of components in the GMM, and D is the dimension of local context descriptor.
After l 2 normalization on Fisher vector, the embedding can be learnt using an arbitrary recurrent neural network based decoder (Perronnin et al., 2010).
In our experiments (see Section 4), as a proof of concept, we ﬁxed the number of GMMs to K = 1 , since more Gaussians would have increased the dimension acted upon by the decoder, making the training computational time prohibitive (for D = 256 , choosing
K ≥ 2 implies a Fisher vector’s dimension greater than a thousand).
VLAD encoding In this case, the context vectors are represented as Vector of Locally Aggregated
Descriptors (VLAD, Jégou et al. (2010); Arandjelovic & Zisserman (2013)).
VLAD is a feature encoding and pooling method, similar to Fisher Vectors.
It encodes a set of local feature descriptors extracted from a sequence and denoted as W = ( w 1 , . . .
, w n : w ∈ R D ) , using a clustering method such as K-means.
Let q ik be the hard assignment of data vectors w i to the k th cluster, such that q ik ≥ 0 and (cid:80)
Kk =1 q ik = 1 .
Furthermore, the assignments of features to dictionary elements must be pre-computed, for example by using KD-trees (Beis & Lowe, 1997; Silpa-Anan & Hartley, 2008).
VLAD encodes features W by considering the residuals
[Equation]
where µ k ∈ R N is the k th cluster centre (or mean).
Then, these residuals are stacked together to obtain the ﬁnal context vector.
GeoSeq2Seq Our novel contribution is to couple a Seq2Seq model with information geometric representation of the context vector.
To do so, we start with a general Seq2Seq trained model.
For each source-destination tuple, we use this encoder to compute the context vectors, which have identical same size (i.e., either 256 or 512 as speciﬁed in the Results section).
Then, we train the GMM on the context vectors obtained from the training sequences and ﬁnally use the means and variances to construct the Fisher Vectors.
Similarly, for the VLAD-based approach, we train the centres and assignments from K-means and KD-trees on the context vectors obtained from the training sequences.
We then use them to generate the VLAD encoding.
Subsequently, we use the new context vectors encoded with FV/VLAD as an initial hidden state to train the decoder, ﬁnally providing us with the shortest path as output.
As the work of Sydorov et al.
(2014) suggests it is possible to learn the Fisher kernel parameters in an end-to-end manner for a convolutional neural network.
A future development for this current work will be to inquire whether end-to-end training of Fisher encoding for Seq2Seq models can be attained.
R ESULTS 4. S HORTEST PATH PROBLEM
For the graph of Minnesota with n = 376 nodes and 455 edges, we generated 3,000 shortest routes between two nodes picking them uniformly at random) and using the A ∗ algorithm with a heuristic based on the Euclidean distance.
We used these routes as the training set for the Seq2Seq algorithms using a 67-33% training-test splits; we train the network for 400 epochs, updating the parameters with an Adam optimisation scheme (Kingma & Ba, 2014), with parameters β 1 = 0 .
9 and β 2 = 0 .
999 , starting from a learning rate equal to 10 − 3 .
Since Fisher encoding requires a double length for the context vector (it considers means and covariances, see Eqn.
, we compared it to a basic Seq2Seq with 256 and 512 hidden units.
On the other hand, VLAD encodes only the residual (see Eqn.
(8)), therefore we instantiate it with 256 and 512 hidden units.
[Figure]
Moreover, in the decoder, the following node in the predicted sequence is computed choosing among all the other n − 1 nodes from a softmax distribution.
If we stop the training early, for example, after only 40 epochs (see Figure 2), the network cannot reproduce possible paths (see Figure 3 on the left-hand side).
On the other hand, if we train the network for more epochs, the training converges after 400 epochs (green dot in Figure 2).
Therefore, as shown in Figure 3 (right), if we compute two paths, one starting from the source (magenta dash-dotted line) and the other from the destination (cyan), intersecting them allows us to predict the shortest path (red).
This is equal to the one generated by A ∗ (green).
This means that the network is capable of learning the adjacency matrix of the graph.
Then, comparing different approaches, the prediction accuracy on the test data-set is reported in Table 1.
As we can see, for what concerns the RNN decoder, doubling the hidden state dimension marginally increases the percentage of shortest paths ( 1% ) and the successful paths, that are not necessarily the shortest ( 0 .
2% and 1 .
6% for GRU and LSTM encoders, respectively).
Our proposed information geometry based Fisher encoding achieves an increased accuracy in ﬁnding the shortest paths ( 56% and 60% for LSTM and GRU, respectively).
Furthermore, if a VLAD encoding is employed, GRU networks have a higher approximation capability with more than 65% of accuracy on the shortest paths and 83% on the successful cases.
Similarly, if the decoder is an LSTM, the accuracies on the shortest paths of simple Seq2Seq models are around 50% , while our GeoSeq2Seq models with Fisher encoding we get close to 60% and even above with the VLAD encoding, achieving 65% (and 82% of successful paths) in the case of the LSTM encoder.
This means that our probabilistic representation of the latent embedding supersedes the non-probabilistic one by 10-15%.
graphsource
[Figure]
[Figure]
[Figure] [Figure]
Method
Shortest
Successful
LSTM2RNN
[Table]
LSTM2RNN
[Table]
GRU2RNN
[Table]
GRU2RNN
[Table]
[Table]
LSTM2RNN with FV 56%
[Table]
GRU2RNN with FV
[Table]
LSTM2RNN with VLAD (256)
[Table]
LSTM2RNN with VLAD (512)
[Table]
GRU2RNN with VLAD (256)
[Table]
GRU2RNN with VLAD (512)
[Table]
LSTM2LSTM (256)
[Table]
LSTM2LSTM
[Table]
4. N EURAL T URING M ACHINES TASKS
In order to provide more generality to our method, in this section, we apply the GeoSeq2Seq model to solve algorithmic tasks similar to those on which Neural Turing Machines (NTM) were evaluated
Graves et al.
(2014), albeit without a need for an external memory module.
Speciﬁcally, we present results for a simple algorithmic task such as copying, and a more complex semantic task such as associative recall.
For these tasks, we used an LSTM2LSTM with VLAD encoding and followed a conﬁguration of hyper-parameters similar to the one in Graves et al.
(2014) i.e. we used RMSProp algorithm with momentum set to 0.9, a learning rate equal to 1e-4 and clipped the gradient during the backpropagation to the range (-10,10).
Copying task
The copying task consists in remembering an eight bit random binary input sequence between a start ﬂag and a stop ﬂag and copying it in the output sequence after the stop ﬂag (see
Figure 4).
As we can see, our method can copy both shorter (Figure 4a) and longer sequences (Figure 4b).
We run 1e5 experiments as test sequences, with random lengths between 2 and 20.
Just like
NTMs all of them were reproduced at the output.
one.
The third item is repeated almost correctly: the ﬁrst two columns are correct, while the last one misses some components.
Associative recall task
The associative recall task consists in remembering an input sequence of item bounded on the left and right by a delimiter ﬂag and repeating the item following the one between the two query ﬂags in the output sequence (see Figure 5).
We deﬁne an item as a sequence of three random binary columns.
For 1e5 test experiments with a random length of the sequence between 2 and 12 items, we achieve an accuracy equal to 13.39%.
This apparently low accuracy is because, as we can see, our GeoSeq2Seq can reproduce the correct next item (Figure 5a) for shorter sequences, while it may fail in few components when the sequence becomes longer (Figure 5b), which is considered an error, as well.
D ISCUSSION
This paper proposes the GeoSeq2Seq , an information geometric Seq2Seq architecture that utilises an information geometric embedding of the context vector.
The RNN is tasked with learning the adjacency matrix of the graph such that at each decision step the search space becomes n − 1 , where n is the total number of nodes in the graph.
Unlike algorithms like q-routing (Boyan & Littman, 1994) that constrains the search space to contain only the connected neighbours, our instantiation of the Seq2Seq operates under a larger search space.
Indeed, the accuracy of our algorithm is expected to increase where we use neighbourhood information from the adjacency matrix.
In summary, such a recurrent network shows increased ﬁdelity for approximating the shortest route produced by a meta-heuristic algorithm.
Apart from encoding, context vector stacking using dual encoders have been proven to be beneﬁcial (Bay & Sengupta, 2018).
Utilising homotopy based continuation has been a different line of work where the emphasis lies in smoothing the loss function of the recurrent network by convolving it with a Gaussian kernel (Bay & Sengupta, 2017).
All of these strategies have shown to improve the temporal memory of the recurrent network.
This line of work is distinct from architecture engineering, that has placed emphasis on constructing exquisite memory mechanism for the recurrent networks.
For example, Neural Turing Machines (Graves et al., 2014) are augmented recurrent networks that have a (differentiable) external memory that can be selectively read or written to, enabling the network to store the latent structure of the sequence.
Attention networks, on the other hand, enable the recurrent networks to attend to snippets of their inputs ( cf.
in conversational modelling Vinyals & Le (2015)).
Similarly, it is also possible to embed the nodes of the graph as preprocessing step using methods such as – (a) DeepWalk (Perozzi et al., 2014), that uses local information obtained from truncated random walks to encode social relations by treating walks as the equivalent of sentences, (b) LINE (Tang et al., 2015), which optimises an objective function preserving both local and global structures, and (c) node2vec (Grover & Leskovec, 2016), that learns continuous feature representations for nodes in networks.
Nevertheless, for the long-term dependencies that shortest paths in large graphs inherit, these methods are small steps towards alleviating the central problem of controlling spectral radius in recurrent neural networks.
The 4-5% gain in accuracy for VLAD in contrast to Fisher encoding is a bit surprising.
As a matter of fact, Fisher encoding should be more precise since it takes covariances into account.
We notice that the covariances matrix (instantiated as a diagonal matrix due to computational constraint) has a high condition number.
The condition number κ of a matrix M is deﬁned as κ ( M )
= (cid:107) M (cid:107)(cid:107) M − 1 (cid:107) , or equivalently it is the ratio of the largest singular value of that matrix to its smallest singular value (Belsley et al., 2005).
Practically, it measures how much small variation in the input argument can propagate to the output value.
In particular, we obtain a condition number equal to 2.69e3 and 1.70e for the LSTM and GRU encoders, respectively.
We believe it is for this reason that the GRU encoder leads to a better accuracy than the LSTM encoder, as shown in Table 1.
The use of Riemann geometry to encode context (feature) vector has a long history in computer vision (Srivastava & Turaga, 2015), our work demonstrates yet another way to embed the curved geometry of the context vector for decoding.
The Riemannian metric for a recurrent network can be evaluated in two ways – one where we describe the probability distribution over the entire sequence and another where we describe a conditional distribution at time i conditioned on time i − 1 .
We anticipate that the latter is more suited to a dynamic scenario (where the structure of the graph may be slowly changing) while the former is more suitable for static graphs.
Analytically, averaging over time and assuming ergodicity, both metric should be fairly close to one another, nonetheless, it is only with further experiments we can demonstrate the value of one over the other.
In this paper, we have constrained the use of the Riemannian metric on the encoding end, one can follow a similar treatise for the decoder.
Together with architecture engineering (Graves et al.,
2014), natural gradient-based optimization (Pascanu & Bengio, 2013), homotopy continuation (Bay & Sengupta, 2017) and ensembling of recurrent encoders (Bay & Sengupta, 2018), we posit that understanding the information geometry of recurrent networks can take us a step closer to ﬁnessing the temporal footprint of a sequence learning network.