Trellis Networks for Sequence Modeling

Shaojie Bai, J. Zico Kolter, Vladlen Koltun

Introduction

What is the best architecture for sequence modeling? Recent research has produced significant progress on multiple fronts. Recurrent networks, such as LSTMs, continue to be optimized and extended (Merity et al., 2018b; Melis et al., 2018; Yang et al., 2018; Trinh et al., 2018). Temporal convolutional networks have demonstrated impressive performance, particularly in modeling long-range context (van den Oord et al., 2016; Dauphin et al., 2017; Bai et al., 2018). And architectures based on self-attention are gaining ground (Vaswani et al., 2017; Santoro et al., 2018).

In this paper, we introduce a new architecture for sequence modeling, the Trellis Network. We aim to both improve empirical performance on sequence modeling benchmarks and shed light on the relationship between two existing model families: recurrent and convolutional networks.

On the one hand, a trellis network is a special temporal convolutional network, distinguished by two unusual characteristics. First, the weights are tied across layers. That is, weights are shared not only by all time steps but also by all network layers, tying them into a regular trellis pattern. Second, the input is injected into all network layers. That is, the input at a given time-step is provided not only to the first layer, but directly to all layers in the network. So far, this may seem merely as a peculiar convolutional network for processing sequences, and not one that would be expected to perform particularly well.

Yet on the other hand, we show that trellis networks generalize truncated recurrent networks (recurrent networks with bounded memory horizon). The precise derivation of this connection is one of the key contributions of our work. It allows trellis networks to serve as bridge between recurrent and convolutional architectures, benefitting from algorithmic and architectural techniques developed in either context. We leverage these relationships to design high-performing trellis networks that absorb ideas from both architectural families. Beyond immediate empirical gains, these connections may serve as a step towards unification in sequence modeling.

We evaluate trellis networks on challenging benchmarks, including word-level language modeling on the standard Penn Treebank (PTB) and the much larger WikiText-103 (WT103) datasets; character-level language modeling on Penn Treebank; and standard stress tests (e.g. sequential MNIST, permuted MNIST, etc.) designed to evaluate long-term memory retention. On word-level Penn Treebank, a trellis network outperforms by more than a unit of perplexity the recent architecture search work of Pham et al. (2018), as well as the recent results of Melis et al. (2018), which leveraged the Google Vizier service for exhaustive hyperparameter search. On character-level Penn Treebank, a trellis network outperforms the thorough optimization work of Merity et al. (2018a). On word-level WikiText-103, a trellis network outperforms by 7.6% in perplexity the contemporaneous self-attention-based Relational Memory Core (Santoro et al., 2018), and by 11.5% the work of Merity et al. (2018a). (Concurrently with our work, Dai et al. (2019) employ a transformer and achieve even better results on WikiText-103.) On stress tests, trellis networks outperform recent results achieved by recurrent networks and self-attention (Trinh et al., 2018). It is notable that the prior state of the art across these benchmarks was held by models with sometimes dramatic mutual differences.

Background

Recurrent networks (Elman, 1990; Werbos, 1990; Graves, 2012), particularly with gated cells such as LSTMs (Hochreiter & Schmidhuber, 1997) and GRUs (Cho et al., 2014), are perhaps the most popular architecture for modeling temporal sequences. Recurrent architectures have been used to achieve breakthrough results in natural language processing and other domains (Sutskever et al., 2011; Graves, 2013; Sutskever et al., 2014; Bahdanau et al., 2015; Vinyals et al., 2015; Karpathy & Li, 2015). Convolutional networks have also been widely used for sequence processing (Waibel et al., 1989; Collobert et al., 2011). Recent work indicates that convolutional networks are effective on a variety of sequence modeling tasks, particularly ones that demand long-range information propagation (van den Oord et al., 2016; Kalchbrenner et al., 2016; Dauphin et al., 2017; Gehring et al., 2017; Bai et al., 2018). A third notable approach to sequence processing that has recently gained ground is based on self-attention (Vaswani et al., 2017; Santoro et al., 2018; Chen et al., 2018). Our work is most closely related to the first two approaches. In particular, we establish a strong connection between recurrent and convolutional networks and introduce a model that serves as a bridge between the two. A related recent theoretical investigation showed that under a certain stability condition, recurrent networks can be well-approximated by feed-forward models (Miller & Hardt, 2018).

There have been many combinations of convolutional and recurrent networks (Sainath et al., 2015). For example, convolutional LSTMs combine convolutional and recurrent units (Donahue et al., 2015; Venugopalan et al., 2015; Shi et al., 2015). Quasi-recurrent neural networks interleave convolutional and recurrent layers (Bradbury et al., 2017). Techniques introduced for convolutional networks, such as dilation, have been applied to RNNs (Chang et al., 2017). Our work establishes a deeper connection, deriving a direct mapping across the two architectural families and providing a structural bridge that can incorporate techniques from both sides.

Sequence Modeling and Trellis Networks

Sequence modeling. Given an input x1:T=x1,…,xTx_{1:T}=x_{1},\dots,x_{T} with sequence length TT, a sequence model is any function G:XT→YT{G:\mathcal{X}^{T}\rightarrow\mathcal{Y}^{T}} such that

where yty_{t} should only depend on x1:tx_{1:t} and not on xt+1:Tx_{t+1:T} (i.e. no leakage of information from the future). This causality constraint is essential for autoregressive modeling.

In this section, we describe a new architecture for sequence modeling, referred to as a trellis network or TrellisNet. In particular, we provide an atomic view of TrellisNet, present its fundamental features, and highlight the relationship to convolutional networks. Section 4 will then elaborate on the relationship of trellis networks to convolutional and recurrent models.

𝑡1t+1, layers ii and i+1i+1) and on a longer sequence (time steps 11 to 88, layers ii and i+1i+1). A basic trellis network. At the most basic level, a feature vector zt+1(i+1)z_{t+1}^{(i+1)} at time step t+1t+1 and level i+1i+1 of TrellisNet is computed via three steps, illustrated in Figure 1(a):

The activation function ff in Equation (3) can be any nonlinearity that processes the pre-activation output z^1:T(i+1)\hat{z}_{1:T}^{(i+1)}and the output from the previous layer z1:T−1(i)z_{1:T-1}^{(i)}. We will later describe an activation function based on the LSTM cell. The rationale for its use will become clearer in light of the analysis presented in the next section.

TrellisNet, TCN, and RNN

In this section, we analyze the relationships between trellis networks, convolutional networks, and recurrent networks. In particular, we show that trellis networks can serve as a bridge between convolutional and recurrent networks. On the one hand, TrellisNet is a special form of temporal convolutional networks (TCN); this has already been clear in Section 3 and will be discussed further in Section 4.1. On the other hand, any truncated RNN can be represented as a TrellisNet with special structure in the interlayer transformations; this will be the subject of Section 4.2. These connections allow TrellisNet to harness architectural elements and regularization techniques from both TCNs and RNNs; this will be summarized in Section 4.3.

We briefly introduce TCNs here, and refer the readers to Bai et al. (2018) for a more thorough discussion. Briefly, a temporal convolutional network (TCN) is a ConvNet that uses one-dimensional convolutions over the sequence. The convolutions are causal, meaning that, at each layer, the transformation at time tt can only depend on previous layer units at times tt or earlier, not from later points in time. Such approaches were used going back to the late 1980s, under the name of “time-delay neural networks” (Waibel et al., 1989), and have received significant interest in recent years due to their application in architectures such as WaveNet (van den Oord et al., 2016).

In essence, TrellisNet is a special kind of temporal convolutional network. TCNs have two distinctive characteristics: 1) causal convolution in each layer to satisfy the causality constraint and 2) deep stacking of layers to increase the effective history length (i.e. receptive field). Trellis networks have both of these characteristics. The basic model presented in Section 3 can easily be elaborated with larger kernel sizes, dilated convolutions, and other architectural elements used in TCNs; some of these are reviewed further in Section 4.3.

2 TrellisNet and RNN

Recurrent networks appear fundamentally different from convolutional networks. Instead of operating on all elements of a sequence in parallel in each layer, an RNN processes one input element at a time and unrolls in the time dimension. Given a non-linearity gg (which could be a sigmoid or a more elaborate cell), we can summarize the transformations in an LL-layer RNN at time-step tt as follows:

Despite the apparent differences, we will now show that any RNN unrolled to a finite length is equivalent to a TrellisNet with special sparsity structure in the kernel matrix WW. We begin by formally defining the notion of a truncated (i.e. finite-horizon) RNN.

Given an RNN ρ\rho, a corresponding M\mathbf{M}-truncated RNN ρM\rho^{M}, applied to the sequence x1:Tx_{1:T}, produces at time step tt the output yty_{t} by applying ρ\rho to the sequence xt−M+1:tx_{t-M+1:t} (here x<0=0x_{<0}=0).

Let ρM\rho^{M} be an MM-truncated RNN with LL layers and hidden unit dimensionality dd. Then there exists an equivalent TrellisNet τ\tau with depth (M+L−1)(M+L-1) and layer width (i.e. number of channels in each hidden layer) LdLd. Specifically, for any x1:Tx_{1:T}, ρM(x1:T)=τL(d−1)+1:Ld(x1:T)\rho^{M}(x_{1:T})=\tau_{L(d-1)+1:Ld}(x_{1:T}) (i.e. the TrellisNet outputs contain the RNN outputs).

Theorem 1 states that any MM-truncated RNN can be represented as a TrellisNet. How severe of a restriction is MM-truncation? Note that MM-truncation is intimately related to truncated backpropagation-through-time (BPTT), used pervasively in training recurrent networks on long sequences. While RNNs can in principle retain unlimited history, there is both empirical and theoretical evidence that the memory horizon of RNNs is bounded (Bai et al., 2018; Khandelwal et al., 2018; Miller & Hardt, 2018). Furthermore, if desired, TrellisNets can recover exactly a common method of applying RNNs to long sequences – hidden state repackaging, i.e. copying the hidden state across subsequences. This is accomplished using an analogous form of hidden state repackaging, detailed in Appendix B.

Let t∈[T]t\in[T] , j≥0j\geq 0 be arbitrary and fixed. We now claim that the hidden unit at time tt and layer jj of TrellisNet τ\tau can be expressed in terms of hidden units at time tt in truncated forms of ρ\rho:

where zt(j)z_{t}^{(j)} is the time-tt hidden state at layer jj of τ\tau and ht,t′(i)h_{t,t^{\prime}}^{(i)} is the time-tt hidden state at layer ii of ρt−t′+1\rho^{t-t^{\prime}+1}.

We prove Eq. (6) by induction on jj. As a base case, consider j=0j=0; i.e. the input layer of τ\tau. Since ht,t′=0h_{t,t^{\prime}}=0 when t′>tt^{\prime}>t, we have that zj(0)=[0  0  …  0]⊤z_{j}^{(0)}=[0\ \ 0\ \ \dots\ \ 0]^{\top}. (Recall that in the input layer of TrellisNet we initialize zt(0)=0z_{t}^{(0)}=\mathbf{0}.) For the inductive step, suppose Eq. (6) holds for layer jj, and consider layer j+1j+1. By the feed-forward transformation of TrellisNet defined in Eq. (2) and the nonlinearity ff we defined above, we have:

where in Eq. (18) we apply the RNN non-linearity gg following Eq. (4). Therefore, by induction, we have shown that Eq. (6) holds for all j≥0j\geq 0.

If TrellisNet τ\tau has M+L−1M+L-1 layers, then at the final layer we have zt(M+L−1)=[…  …  ht,t+1−M(L)]⊤z_{t}^{(M+L-1)}=[\dots\ \ \dots\ \ h_{t,t+1-M}^{(L)}]^{\top}. Since ρM\rho^{M} is an LL-layer MM-truncated RNN, this (taking the last dd channels of zt(M+L−1)z_{t}^{(M+L-1)}) is exactly the output of ρM\rho^{M} at time tt.

In other words, we have shown that ρM\rho^{M} is equivalent to a TrellisNet with sparse kernel matrices W1,W2W_{1},W_{2}. This completes the proof. ∎

Note that the convolutions in the TrellisNet τ\tau constructed in Theorem 1 are sparse, as shown in Eq. (5). They are related to group convolutions (Krizhevsky et al., 2012), but have an unusual form because group kk at time tt is convolved with group k−1k-1 at time t+1t+1. We refer to these as mixed group convolutions. Moreover, while Theorem 1 assumes that all layers of ρM\rho^{M} have the same dimensionality dd for clarity, the proof easily generalizes to cases where each layer has different widths.

For didactic purposes, we recap and illustrate the construction in the case of a 2-layer RNN. The key challenge is that a naïve unrolling of the RNN into a feed-forward network does not produce a convolutional network, since the linear transformation weights are not constant across a layer. The solution, illustrated in Figure 2(a), is to organize each hidden unit into groups of channels, such that each TrellisNet unit represents 3 RNN units simultaneously (for xt,ht(1),ht(2)x_{t},h_{t}^{(1)},h_{t}^{(2)}). Each TrellisNet unit thus has (p+2d)(p+2d) channels. The interlayer transformation can then be expressed as a mixed group convolution, illustrated in Figure 2(b). This can be represented as a sparse convolution with the structure given in Eq. (5) (with L=2L=2). Applying the nonlinearity gg on the pre-activation output, this exactly reproduces the transformations in the original 2-layer RNN.

The TrellisNet that emerges from this construction has special sparsity structure in the weight matrix. It stands to reason that a general TrellisNet with an unconstrained (dense) weight matrix WW may have greater expressive power: it can model a broader class of transformations than the original RNN ρM\rho^{M}. Note that while the hidden channels of the TrellisNet τ\tau constructed in the proof of Theorem 1 are naturally arranged into groups that represent different layers of the RNN ρM\rho^{M} (Eq. (6)), an unconstrained dense weight matrix WW no longer admits such an interpretation. A model defined by a dense weight matrix is fundamentally distinct from the RNN ρM\rho^{M} that served as our point of departure. We take advantage of this expressivity and use general weight matrices WW, as presented in Section 3, in our experiments. Our ablation analysis will show that such generalized dense transformations are beneficial, even when model capacity is controlled for.

The proof of Theorem 1 did not delve into the inner structure of the nonlinear transformation gg in RNN (or ff in the constructed TrellisNet). For a vanilla RNN, for instance, ff is usually an elementwise sigmoid or tanh⁡\tanh function. But the construction in Theorem 1 applies just as well to RNNs with structured cells, such as LSTMs and GRUs. We adopt LSTM cells for the TrellisNets in our experiments and provide a detailed treatment of this nonlinearity in Section 5.1 and Appendix A.

3 TrellisNet as a Bridge Between Recurrent and Convolutional Models

In Section 4.1 we concluded that TrellisNet is a special kind of TCN, characterized by weight tying and input injection. In Section 4.2 we established that TrellisNet is a generalization of truncated RNNs. These connections along with the construction in our proof of Theorem 1 allow TrellisNets to benefit significantly from techniques developed originally for RNNs, while also incorporating architectural and algorithmic motifs developed for convolutional networks. We summarize a number of techniques here. From recurrent networks, we can integrate 1) structured nonlinear activations (e.g. LSTM and GRU gates); 2) variational RNN dropout (Gal & Ghahramani, 2016); 3) recurrent DropConnect (Merity et al., 2018b); and 4) history compression and repackaging. From convolutional networks, we can adapt 1) larger kernels and dilated convolutions (Yu & Koltun, 2016); 2) auxiliary losses at intermediate layers (Lee et al., 2015; Xie & Tu, 2015); 3) weight normalization (Salimans & Kingma, 2016); and 4) parallel convolutional processing. Being able to directly incorporate techniques from both streams of research is one of the benefits of trellis networks. We leverage this in our experiments and provide a more comprehensive treatment of these adaptations in Appendix B.

Experiments

In our description of generic trellis networks in Section 3, the activation function ff can be any nonlinearity that computes z1:T(i+1)z_{1:T}^{(i+1)} based on z^1:T(i+1)\hat{z}_{1:T}^{(i+1)} and z1:T−1(i)z_{1:T-1}^{(i)}. In experiments, we use a gated activation based on the LSTM cell. Gated activations have been used before in convolutional networks for sequence modeling (van den Oord et al., 2016; Dauphin et al., 2017). Our choice is inspired directly by Theorem 1, which suggests incorporating an existing RNN cell into TrellisNet. We use the LSTM cell due to its effectiveness in recurrent networks (Jozefowicz et al., 2015; Greff et al., 2017; Melis et al., 2018). We summarize the construction here; a more detailed treatment can be found in Appendix A.

In an LSTM cell, three information-controlling gates are computed at time tt. Moreover, there is a cell state that does not participate in the hidden-to-hidden transformations but is updated in every step using the result from the gated activations. We integrate the LSTM cell into the TrellisNet as follows (Figure 3):

Thus the linear transformation in each layer of the TrellisNet produces a pre-activation feature z^t+1\hat{z}_{t+1} with r=4qr=4q feature channels, which are then processed by elementwise transformations and Hadamard products to yield the final output zt+1(i+1)=(zt+1,1(i+1),zt+1,2(i+1))z_{t+1}^{(i+1)}=\left(z_{t+1,1}^{(i+1)},z_{t+1,2}^{(i+1)}\right) of the layer.

2 Results

We evaluate trellis networks on word-level and character-level language modeling on the standard Penn Treebank (PTB) dataset (Marcus et al., 1993; Mikolov et al., 2010), large-scale word-level modeling on WikiText-103 (WT103) (Merity et al., 2017), and standard stress tests used to study long-range information propagation in sequence models: sequential MNIST, permuted MNIST (PMNIST), and sequential CIFAR-10 (Chang et al., 2017; Bai et al., 2018; Trinh et al., 2018). Note that these tasks are on very different scales, with unique properties that challenge sequence models in different ways. For example, word-level PTB is a small dataset that a typical model easily overfits, so judicious regularization is essential. WT103 is a hundred times larger, with less danger of overfitting, but with a vocabulary size of 268K that makes training more challenging (and precludes the application of techniques such as mixture of softmaxes (Yang et al., 2018)). A more complete description of these tasks and their characteristics can be found in Appendix C.

The prior state of the art on these tasks was set by completely different models, such as AWD-LSTM on character-level PTB (Merity et al., 2018a), neural architecture search on word-level PTB (Pham et al., 2018), and the self-attention-based Relational Memory Core on WikiText-103 (Santoro et al., 2018). We use trellis networks on all tasks and outperform the respective state-of-the-art models on each. For example, on word-level Penn Treebank, TrellisNet outperforms by a good margin the recent results of Melis et al. (2018), which used the Google Vizier service for exhaustive hyperparameter tuning, as well as the recent neural architecture search work of Pham et al. (2018). On WikiText-103, a trellis network outperforms by 7.6% the Relational Memory Core (Santoro et al., 2018) and by 11.5% the thorough optimization work of Merity et al. (2018a).

Many hyperparameters we use are adapted directly from prior work on recurrent networks. (As highlighted in Section 4.3, many techniques can be carried over directly from RNNs.) For others, we perform a basic grid search. We decay the learning rate by a fixed factor once validation error plateaus. All hyperparameters are reported in Appendix D, along with an ablation study.

Word-level language modeling. For word-level language modeling, we use PTB and WT103. The results on PTB are listed in Table 1. TrellisNet sets a new state of the art on PTB, both with and without mixture of softmaxes (Yang et al., 2018), outperforming all previously published results by more than one unit of perplexity.

WT103 is 110 times larger than PTB, with vocabulary size 268K. We follow prior work and use the adaptive softmax (Grave et al., 2017a), which improves memory efficiency by assigning higher capacity to more frequent words. The results are listed in Table 2. TrellisNet sets a new state of the art on this dataset as well, with perplexity 29.19: about 7.6% better than the contemporaneous self-attention-based Relational Memory Core (RMC) (Santoro et al., 2018). TrellisNet achieves this better accuracy with much faster convergence: 25 epochs, versus 90 for RMC.

Character-level language modeling. When used for character-level modeling, PTB is a medium-scale dataset with stronger long-term dependencies between characters. We thus use a deeper network as well as techniques such as weight normalization (Salimans & Kingma, 2016) and deep supervision (Lee et al., 2015; Xie & Tu, 2015). The results are listed in Table 3. TrellisNet sets a new state of the art with 1.158 bpc, outperforming the recent results of Merity et al. (2018a) by a comfortable margin.

Long-range modeling with Sequential MNIST, PMNIST, and CIFAR-10. We also evaluate the TrellisNet for ability to model long-term dependencies. In the Sequential MNIST, PMNIST, and CIFAR-10 tasks, images are processed as long sequences, one pixel at a time (Chang et al., 2017; Bai et al., 2018; Trinh et al., 2018). Our model has 8M parameters, in alignment with prior work. To cover the larger context, we use dilated convolutions in intermediate layers, adopting a common architectural element from TCNs (Yu & Koltun, 2016; van den Oord et al., 2016; Bai et al., 2018). The results are listed in Table 4. Note that the performance of prior models is inconsistent. The Transformer works well on MNIST but fairs poorly on CIFAR-10, while rr-LSTM with unsupervised auxiliary losses achieves good results on CIFAR-10 but underperforms on Permuted MNIST. TrellisNet outperforms all these models on all three tasks.

Discussion

We presented trellis networks, a new architecture for sequence modeling. Trellis networks form a structural bridge between convolutional and recurrent models. This enables direct assimilation of many techniques designed for either of these two architectural families. We leverage these connections to train high-performing trellis networks that set a new state of the art on highly competitive language modeling benchmarks. Beyond the empirical gains, we hope that trellis networks will serve as a step towards deeper and more unified understanding of sequence modeling.

There are many exciting opportunities for future work. First, we have not conducted thorough performance optimizations on trellis networks. For example, architecture search on the structure of the gated activation ff may yield a higher-performing activation function than the classic LSTM cell we used (Zoph & Le, 2017; Pham et al., 2018). Likewise, principled hyperparameter tuning will likely improve modeling accuracy beyond the levels we have observed (Melis et al., 2018). Future work can also explore acceleration schemes that speed up training and inference.

Another significant opportunity is to establish connections between trellis networks and self-attention-based architectures (Transformers) (Vaswani et al., 2017; Santoro et al., 2018; Chen et al., 2018), thus unifying all three major contemporary approaches to sequence modeling. Finally, we look forward to seeing applications of trellis networks to industrial-scale challenges such as machine translation.

References

Appendix A Expressing an LSTM as a TrellisNet

Here we trace in more detail the transformation of an LSTM into a TrellisNet. This is an application of Theorem 1. The nonlinear activation has been examined in Section 5.1. We will walk through the construction again here.

In each time step, an LSTM cell computes the following:

where ht(0)=xth_{t}^{(0)}=x_{t}, and ft,it,otf_{t},i_{t},o_{t} are typically called the forget, input, and output gates. By a similar construction to how we defined τ\tau in Theorem 1, to recover an LSTM the mixed group convolution needs to produce 3q3q more channels for these gated outputs, which have the form ft,t′,it,t′f_{t,t^{\prime}},i_{t,t^{\prime}} and gt,t′g_{t,t^{\prime}} (see Figure 5 for an example). In addition, at each layer of the mixed group convolution, the network also needs to maintain a group of channels for cell states ct,t′c_{t,t^{\prime}}. Note that in an LSTM network, ctc_{t} is updated “synchronously” with hth_{t}, so we can similarly write

Based on these changes, we show in Figure 4 an atomic and a sequence view of TrellisNet with the LSTM activation. The hidden units z1:Tz_{1:T} consist of two parts: z1:T,1z_{1:T,1}, which gets updated directly via the gated activations (akin to LSTM cell states), and z1:T,2z_{1:T,2}, which is processed by parameterized convolutions (akin to LSTM hidden states). Formally, in layer ii:

Appendix B Optimizing and Regularizing TrellisNet with RNN and TCN Methods

In Section 4, we formally described the relationship between TrellisNets, RNNs, and temporal convolutional networks (TCN). On the one hand, TrellisNet is a special TCN (with weight-tying and input injection), while on the other hand it can also express any structured RNN via a sparse convolutional kernel. These relationships open clear paths for applying techniques developed for either recurrent or convolutional networks. We summarize below some of the techniques that can be applied in this way to TrellisNet, categorizing them as either inspired by RNNs or TCNs.

History repackaging. One theoretical advantage of RNNs is their ability to represent a history of infinite length. However, in many applications, sequence lengths are too long for infinite backpropagation during training. A typical solution is to partition the sequence into smaller subsequences and perform truncated backpropagation through time (BPTT) on each. At sequence boundaries, the hidden state hth_{t} is “repackaged” and passed onto the next RNN sequence. Thus gradient flow stops at sequence boundaries (see Figure 6(a)). Such repackaging is also sometimes used at test time.

We can now map this repackaging procedure to trellis networks. As shown in Figure 6, the notion of passing the compressed history vector hth_{t} in an RNN corresponds to specific non-zero padding in the mixed group convolution of the corresponding TrellisNet. The padding is simply the channels from the last step of the final layer applied on the previous sequence (see Figure 6(b), where without the repackaging padding, at layer 2 we will have hT+1,T+1(1)h_{T+1,T+1}^{(1)} instead of hT+1,1(1)h_{T+1,1}^{(1)}). We illustrate this in Figure 6(b), where we have written out zt(i)z_{t}^{(i)} in TrellisNet explicitly in the form of ht,t′h_{t,t^{\prime}} according to Eq. (6). This suggests that instead of storing all effective history in memory, we can compress history in a feed-forward network to extend its history as well. For a general TrellisNet that employs a dense kernel, similarly, we can pass the hidden channels of the last step of the final layer in the previous sequence as the “history” padding for the next TrellisNet sequence (this works in both training and testing).

Gated activations. In general, the structured gates in RNN cells can be translated to gated activations in temporal convolutions, as we did in Appendix A in the case of an LSTM. While in the experiments we adopted the LSTM gating, other activations (e.g. GRUs (Cho et al., 2014) or activations found via architecture search (Zoph & Le, 2017)) can also be applied in trellis networks via the equivalence established in Theorem 1.

RNN variational dropout. Variational dropout (VD) for RNNs (Gal & Ghahramani, 2016) is a useful regularization scheme that applies the same mask at every time step within a layer (see Figure 7(a)). A direct translation of this technique from RNN to the group temporal convolution implies that we need to create a different mask for each diagonal of the network (i.e. each history starting point), as well as for each group of the mixed group convolution. We propose an alternative (and extremely simple) dropout scheme for TrellisNet, which is inspired by VD in RNNs as well as Theorem 1. In each iteration, we apply the same mask on the post-activation outputs, at every time step in both the temporal dimension and depth dimension. That is, based on Eq. (6) in Theorem 1, we adapt VD to the TrellisNet setting by assuming ht,t′±δ≈ht,t′h_{t,t^{\prime}\pm\delta}\approx h_{t,t^{\prime}}; see Figure 7(a). Empirically, we found this dropout to work significantly better than other dropout schemes (e.g. drop certain channels entirely).

Recurrent weight dropout/DropConnect. We apply DropConnect on the TrellisNet kernel. Merity et al. (2018b) showed that regularizing hidden-to-hidden weights WhhW_{hh} can be useful in optimizing LSTM language models, and we carry this scheme over to trellis networks.

B.2 From Convolutional Networks

Dense convolutional kernel. Generalizing the convolution from a mixed group (sparse) convolution to a general (dense) one means the connections are no longer recurrent and we are computing directly on the hidden units with a large kernel, just like any temporal ConvNet.

where λ\lambda is a fixed scaling factor that controls the weight of the auxiliary loss.

Note that this technique is not directly transferable (or applicable) to RNNs.

Larger kernel and dilations (Yu & Koltun, 2016). These techniques have been used in convolutional networks to more quickly increase the receptive field. They can be immediately applied to trellis networks. Note that the activation function ff of TrellisNet may need to change if we change the kernel size or dilation settings (e.g. with dilation dd and kernel size 2, the activation will be f(z^1:T(i),z1:T−d(i))f(\hat{z}_{1:T}^{(i)},z_{1:T-d}^{(i)})).

Weight normalization (Salimans & Kingma, 2016). Weight normalization (WN) is a technique that learns the direction and the magnitude of the weight matrix independently. Applying WN on the convolutional kernel was used in some prior works on temporal convolutional architectures (Dauphin et al., 2017; Bai et al., 2018), and have been found useful in regularizing the convolutional filters and boosting convergence.

Parallelism. Because TrellisNet is convolutional in nature, it can easily leverage the parallel processing in the convolution operation (which slides the kernel across the input features). We note that when the input sequence is relatively long, the predictions of the first few time steps will have insufficient history context compared to the predictions later in the sequence. This can be addressed by either history padding (mentioned in Appendix B.1) or chopping off the loss incurred by the first few time steps.

Appendix C Benchmark Tasks

Word-level language modeling on Penn Treebank (PTB). The original Penn Treebank (PTB) dataset selected 2,499 stories from a collection of almost 100K stories published in Wall Street Journal (WSJ) (Marcus et al., 1993). After Mikolov et al. (2010) processed the corpus, the PTB dataset contains 888K words for training, 70K for validation and 79K for testing, where each sentence is marked with an tag at its end. All of the numbers (e.g. in financial news) were replaced with a ? symbol with many punctuations removed. Though small, PTB has been a highly studied dataset in the domain of language modeling (Miyamoto & Cho, 2016; Zilly et al., 2017; Merity et al., 2018b; Melis et al., 2018; Yang et al., 2018). Due to its relatively small size, many computational models can easily overfit on word-level PTB. Therefore, good regularization methods and optimization techniques designed for sequence models are especially important on this benchmark task (Merity et al., 2018b).

Word-level language modeling on WikiText-103. WikiText-103 (WT103) is 110 times larger than PTB, containing a training corpus from 28K lightly processed Wikipedia articles (Merity et al., 2017). In total, WT103 features a vocabulary size of about 268KAs a reference, Oxford English Dictionary only contains less than 220K unique English words., with 103M words for training, 218K words for validation, and 246K words for testing/evaluation. The WT103 corpus also retains the original case, punctuation and numbers in the raw data, all of which were removed from the PTB corpus. Moreover, since WT103 is composed of full articles (whereas PTB is sentence-based), it is better suited for testing long-term context retention. For these reasons, WT103 is typically considered much more representative and realistic than PTB (Merity et al., 2018a).

Character-level language modeling on Penn Treebank (PTB). When used for character-level language modeling, PTB is a medium size dataset that contains 5M chracters for training, 396K for validation, and 446K for testing, with an alphabet size of 50 (note: the tag that marks the end of a sentence in word-level tasks is now considered one character). While the alphabet size of char-level PTB is much smaller compared to the word-level vocabulary size (10K), there is much longer sequential token dependency because a sentence contains many more characters than words.

Sequential and permuted MNIST classification. The MNIST handwritten digits dataset (LeCun et al., 1989) contains 60K normalized training images and 10K testing images, all of size 28×2828\times 28. In the sequential MNIST task, MNIST images are presented to the sequence model as a flattened 784×1784\times 1 sequence for digit classification. Accurate predictions therefore require good long-term memory of the flattened pixels – longer than in most language modeling tasks. In the setting of permuted MNIST (PMNIST), the order of the sequence is permuted at random, so the network can no longer rely on local pixel features for classification.

Sequential CIFAR-10 classification. The CIFAR-10 dataset (Krizhevsky & Hinton, 2009) contains 50K images for training and 10K for testing, all of size 32×3232\times 32. In the sequential CIFAR-10 task, these images are passed into the model one at each time step, flattended as in the MNIST tasks. Compared to sequential MNIST, this task is more challenging. For instance, CIFAR-10 contains more complex image structures and intra-class variations, and there are 3 channels to the input. Moreover, as the images are larger, a sequence model needs to have even longer memory than in sequential MNIST or PMNIST (Trinh et al., 2018).

Appendix D Hyperparameters and Ablation Study

Table 5 specifies the trellis networks used for the various tasks. There are a few things to note while reading the table. First, in training, we decay the learning rate once the validation error plateaus for a while (or according to some fixed schedule, such as after 100 epochs). Second, for auxiliary loss (see Appendix B for more details), we insert the loss function after every fixed number of layers in the network. This “frequency” is included below under the “Auxiliary Frequency” entry. Finally, the hidden dropout in the Table refers to the variational dropout we translated from RNNs (see Appendix B), which is applied at all hidden layers of the TrellisNet. Due to the insight from Theorem 1, many techniques in TrellisNet were translated directly from RNNs or TCNs. Thus, most of the hyperparameters were based on the numbers reported in prior works (e.g. embedding size, embedding dropout, hidden dropout, output dropout, optimizer, weight-decay, etc.) with minor adjustments (Merity et al., 2018b; Yang et al., 2018; Bradbury et al., 2017; Merity et al., 2018a; Trinh et al., 2018; Bai et al., 2018; Santoro et al., 2018). For factors such as auxiliary loss weight and frequency, we perform a basic grid search.

We have also performed an ablation study on TrellisNet to study the influence of various ingredients and techniques on performance. The results are reported in Table 6. We conduct the study on word-level PTB using a TrellisNet with 24M parameters. When we study one factor (e.g. removing hidden dropout), all hyperparameters and settings remain the same as in column 1 of Table 5 (except for “Dense Kernel”, where we adjust the number of hidden units so that the model size remains the same).