C USTOMIZING S EQUENCE G ENERATION WITH M ULTIT ASK D YNAMICAL S YSTEMS
Anonymous authors
Paper under double-blind review
A BSTRACT
Dynamical system models (including RNNs ) often lack the ability to adapt the sequence generation or prediction to a given context limiting their real- world application.
In this paper we show that hierarchical multi-task dynamical systems (MTDSs) provide direct user control over sequence generation, via use of a latent code z that speciﬁes the customization to the individual data sequence.
This enables style transfer, interpolation and morphing within generated sequences.
We show the MTDS can improve predictions via latent code interpolation, and avoid the long-term performance degradation of standard RNN approaches.
I NTRODUCTION
Time series data often arise as a related ‘family’ of sequences, where certain characteristic differences exist between the sequences in a dataset.
Examples include the style of handwritten text (Graves, 2013), the response of a patient to an anaesthetic (Bird et al., 2019), or the style of locomotion in motion capture (mocap) data (Ghosh et al., 2017). In this paper, we will consider how such variation may be modelled, and effectively controlled by an end user.
Such related data is often pooled to train a single dynamical system, despite the internal variation.
For a simple model, such as a linear dynamical system (LDS), this will result in learning only an average effect.
In contrast, a recurrent neural network (RNN) may model this variation, but in an implicit and opaque manner.
Such a ‘black-box’ approach prohibits end-user control, and may suffer from mode drift, such as in Ghosh et al.
(2017), where a generated mocap sequence performs an unprompted transition from walking to drinking.
Some of these problems may be alleviated by appending ‘context labels’ to the inputs (see e.g. Goodfellow et al., 2016, §10.2.4) which describe the required customization.
However, such labels are often unavailable, and the approach may fail to model the variation adequately even when they are.
To move beyond these approaches, we consider latent variable models, where a latent variable z characterizes each sequence.
This may be seen as a form of multi-task learning (MTL, see Zhang & Yang, 2017), from which we derive the name multi-task dynamical system (MTDS), with each sequence treated as a task.
A straightforward approach is to append the latent z to the inputs of the model, similarly to the ‘context label’ approach, thereby providing customization of the various bias (or offset) parameters of the model.
A number of examples of this have been proposed recently, e.g. in Yingzhen & Mandt (2018) and Miladinovi´c et al. Nevertheless, this ‘bias customization’ has limited expressiveness and is often unsuitable for customizing simple models. In this paper we investigate a more powerful form of customization which modulates all the system and emission parameters.
In this approach, the parameters of each task are constrained to lie on a learned low dimensional manifold, indexed by the latent z . Our experiments show that this approach results in improved performance and/or greater data efﬁciency than existing approaches, as well as greater robustness to unfamiliar test inputs. Further, varying z can generate a continuum of models, allowing interpolation between sequence predictions (see Figure 1b for an example), and potentially morphing of sequence characteristics over time.
Contributions In this paper we propose the MTDS, which goes beyond existing work by allowing full adaptation of all parameters of general dynamical systems via use of a learned nonlinear manifold. We show how the approach may be applied to various popular models, and provide general purpose u (1) x (1) y (1) u (1) x (1) y (1) u (1) x (1) y (1) ...
θ (1) ...
u (2) x (2) y (2) u (2) x (2) y (2) u (2) x (2) y (2) ...
θ (2) ...
u ( N )x ( N )y ( N )u ( N )x ( N )y ( N )u ( N )x ( N )y ( N )...
θ ( N ) ...
φ ...
(a)      (b) learning and inference algorithms.
Our experimental studies use synthetic data (sum of two damped harmonic oscillators) and real-world human locomotion mocap data.
We illuminate various properties of the MTDS formulation in our experiments, such as data efﬁciency, user control, and robustness to dataset shift, and show how these go beyond existing approaches to time series modelling.
We ﬁnally utilize the increased user control in the context of mocap data to demonstrate style morphing .
To this end, we introduce the model in Section 2, giving examples and discussing the particular challenges in learning and inference.
We discuss the relation to existing work in Section 3.
Experimental setup and results are given in Section 4 with a conclusion in Section 5.
M ULTI -T ASK D YNAMICAL S YSTEMS
Consider a collection of input-output sequences D
= { Y ( i ) , U ( i ) } Ni =1 with inputs
U ( i ) =
{ u ( i ) 1 , . . .
, u ( i ) T i } and outputs Y ( i ) =
{ y ( i ) 1 , . . .
, y ( i ) T i } , i = 1 , . .
N , where T i denotes the length of sequence i .
Each sequence i is described by a different dynamical system, whose parameter θ ( i ) depends on the hierarchical latent variable z
( i ) ∈
Z :
[Equation]
for t = 1 , . . .
, T i .
The state variables X
( i ) =
{ x ( i ) 1 , . . .
, x ( i ) T i } , x t ∈
X follow the latent dynamics (2) starting from x 0 := 0 (other choices of initial state are possible).
See Figure 1a for a graphical model.
In this paper we assume
Z
= R k which the vector-valued function h φ ( · ) transforms to conformable model parameters θ ∈ R d , d (cid:29) k .
Note that h φ may keep some dimensions of θ constant with respect to z .
We call this a Multi-Task Dynamical System, going beyond the usage in Bird et al.
An MTDS model under this framework must specify three key quantities:
The base model (e.g. a LDS or RNN).
The nature of the interaction between the latent variable z and the parameter vectors θ (e.g. if only the dynamics (eq. 2) depend on θ ).
The choice of prior p ( z ) and transformation h φ .
Where the use of a constant z over time is inappropriate, each sequence can be broken into segments of maximum length L .
When L
2. E XAMPLES
In order to make the framework more concrete we will describe two general choices of the base model.
In what follows we will write each parameter with a subscript z to denote dependence on z (e.g. A z :=
A ( z ) ) to reduce notational clutter.
The choice of p ( z ) and h φ will depend on the application, but a fairly general choice is a deep latent Gaussian model (Kingma & Welling, 2014;
Rezende et al., 2014).
See section A.1.1 in the supplementary material for further discussion.
2.1. M ULTI -T ASK L INEAR D YNAMICAL S YSTEM
For a given z , a multi-task linear dynamical system (MTLDS) can be described by:
[Equation]
w t ∼ N ( 0 , R z ) , (cid:15) t ∼ N ( 0 , S z ) , with θ z
= { A z , B z , b z , C z , D z , d z , R z ,
S z } = h φ ( z ) .
The parameterization of θ z must satisfy the constraints of positive deﬁnite R z and S z and stable A z (i.e.
(cid:107)
A z (cid:107) 2 ≤ 1 ) for all z , hence projection methods such as in Siddiqi et al.
(2008) are not applicable.
We choose an alternative formulation of the LDS, replacing the latent dynamics in eq. (4) by:
[Equation]
(6) where Σ z is a diagonal matrix and Q z orthogonal with no loss of generality (proof in supp.
mat.).
Since (cid:107) Σ z Q z (cid:107) ≤ (cid:107) Σ z (cid:107)(cid:107) Q z (cid:107) =
(cid:107) Σ z (cid:107) , stability can be enforced e.g. by Σ = diag { tanh ( υ ) } for some vector υ .
For more details see section A.1.2 in the supplementary material.
2.1. M ULTI -T ASK R ECURRENT N EURAL N ETWORK
Due to the nonlinearity of an RNN, enforcing stability of A z is not strictly required (see e.g. Miller &
Hardt, 2019, §4.4), although bounding the spectral radius may be useful for learning (e.g. Pascanu et al., 2013).
The dynamics of a multi-task RNN (MT-RNN) are described by:
[Equation]
Combined with the emission model of eq.
(5), we have θ z
=
{ A z , B z , b z , C z , D z , d z } .
If long-term dependencies are important we may consider an orthogonal transition matrix (parameterized as for the MTLDS) to create a multi-task version of the Orthogonal RNN (ORNN, Helfrich et al., 2018).
2. L EARNING
The parameters φ of an MTDS can be learned from a dataset D :=
{ Y ( i ) , U ( i ) } Ni =1 via maximum marginal likelihood: φ ∗ = arg max φ (cid:80)
Ni =1 log p
( Y ( i )
| U ( i ) , φ ) , where
[Equation]
The ﬁrst term in the integrand, p ( Y | U, h φ ( z ))
= (cid:82) X T p ( Y | X, U, h φ ( z ))
p ( X | U, h φ ( z ))
d X is generally intractable for stochastic dynamics (with notable exceptions of discrete and linear-Gaussian models).
A common approach is to use a variational evidence lower bound (ELBO) see e.g. Fraccaro et al.
; Goyal et al.
Miladinovi´c et al.
(2019) or a Monte Carlo objective (MCO) e.g.
Maddison et al.
; Le et al.
; Naesseth et al.
For clarity of exposition we only consider models with deterministic state, which extends to the MTRNN and MTLDS above (in the case w t = 0 for all t ).
This also avoids the interaction effect with the choice of approximate marginalization over X .
Equation (8) also cannot be computed in closed form in general, and so we resort to approximate learning.
A natural choice is via the ELBO (see an alternative MCO approach for unsupervised tasks in Section A.1.3, supp.
mat.).
We write the ELBO of eq.
(8) as:
[Equation]
where D KL is the Kullback-Leibler divergence and q λ ( z | Y, U ) an approximate posterior for z .
We can now optimize a lower bound of the marginal likelihood via arg max φ , λ (cid:80) Ni
=
L ( Y ( i ) ; φ , λ ) , where low variance unbiased gradients of eq.
(9) are available via reparameterization (Kingma &
Welling, 2014; Rezende et al., 2014) and minibatches of size N batch < N .
Optimization via Adam (Kingma & Ba, 2014) proved adequate in our experiments without resorting to any specialized RNN optimization tricks.
A standard choice of q λ ( z | Y, U ) is N ( µ λ ( Y, U ) , s λ
( Y, U )) , where µ λ , s λ are inference networks (e.g. Fabius & van Amersfoort, 2015).
It can be difﬁcult to learn a sensible latent representation if the base model is a powerful RNN.
When each output can be identiﬁed unambiguously via the inputs preceding it, a larger ELBO can be obtained by the RNN learning the relationship without using the latent variable (see e.g. Chen et al., 2017).
A useful heuristic for avoiding such optima is KL annealing (e.g. Bowman et al., 2016).
In our experiments we perform an initial optimization without the KL penalty (second term in eq. 9), initializing s λ ( Y, U ) to a small constant value.
2. I NFERENCE
For an unseen test sequence { Y (cid:48) , U (cid:48) } , the posterior predictive distribution is p ( y (cid:48) t +1: T | y (cid:48) 1: t , u (cid:48) 1: T ) =
(cid:82)
Z p ( y (cid:48) t +1: T | u (cid:48) 1: T , z ) p
( z | y (cid:48) 1: t , u (cid:48) 1: t ) d z , usually estimated via Monte Carlo.
The key quantity is the posterior over z , which may be approximated by the inference networks µ λ , s λ .
However, for novel test sequences, the inference networks may perform poorly and standard approximate inference techniques may be preferred.
For further discussion and a description of our inference approach, see sections A.1.4, A.1.5 in the supp.
mat.
We note that z may not require inference, for instance by using the posterior of a sequence in the the training set.
This may be useful for artistic control, style transfer, embedding domain knowledge or overriding misleading observations.
We also note that the latent code can be varied during the state rollout to simulate a task which varies over time.
R ELATED W ORK
A number of dynamical models following the ‘bias customization’ approach have been proposed recently.
Miladinovi´c et al.
and Hsu et al.
(2017) propose models where the biases of an
LSTM cell depend on a (hierarchical) latent variable.
Yingzhen & Mandt (2018) propose a dynamical system where the latent dynamics are concatenated with a time-constant latent variable. In contrast, our MTDS model performs full parameter customization, and this on both the dynamics and emission distributions.
A number of other proposals may be considered specialized applications of the MTDS.
Bird et al.
(2019) use a small deterministic nonlinear dynamical system for the base model whose parameters depend on z using a nonlinear factor analysis structure.
Spieckermann et al.
(2015) use a small RNN as the base model, where the transition matrix depends on z via multilinear decomposition.
Lin et al.
(2019) use a small stochastic nonlinear dynamical system with h φ a set of parameter vectors chosen discretely (or in convex combination) via z .
Controlling and customizing sequence prediction has received much attention in the case of video data.
As in the MTDS, these approaches learn features that are constant (or slowly varying) within a subsequence.
Denton & Birodkar (2017) and Villegas et al.
(2017) propose methods for disentangling time-varying and static features, but do not provide a useful density over the latter, nor an obvious way to customize the underlying dynamics.
Tulyakov et al.
(2018) use a GAN architecture where z factorizes into content and motion components.
Hsieh et al.
(2018) force a parts-based decomposition of the scene before inferring the latent content z .
However, as before, the dynamic evolution cannot be easily customized with these methods.
Hierarchical approaches for dynamical systems with time-varying parameters are proposed in Luttinen et al.
(2014) (corresponding to non-stationary assumptions) and in Karl et al.
(2017) (for the purposes of local LDS approximation).
These models, like the MTDS can adapt all the parameters, but are linear and correspond to single task problems.
Rangapuram et al.
(2018) predict the parameters of simple time-varying LDS models directly via an RNN.
While this is a multi-task problem, it is assumed that all necessary variation can be inferred from the inputs U .
Multi-task GPs are commonly used for sequence prediction.
Examples include those in Osborne et al.
; Titsias & Lázaro-Gredilla (2011); Álvarez et al. (2012); Roberts et al.
MTGPs however can only be linear combinations of (a small number of) latent functions, further, predictions depend critically upon often unknown mean functions, and inputs are not easily integrated.
Note that an MTDS with no inputs, an LDS base model, a linear-Gaussian prior over the emission parameters [Figure] and ﬁxed dynamics is an MTGP.
In contrast to MTGPs, an MTDS allows much greater ﬂexibility of the dynamic variation.
The MT GP dynamical system of Korkinof & Demiris (2017) mitigates some of these limitations, but it retains a simple linear combination of latent dynamics with a Gaussian density over the combination.
Style transfer has been widely explored for mocap data e.g. Hsu et al.
; Min et al.
; Xia et al.
; Holden et al.
(2017a), but
in most previous work, generating sequences conditioned on a trajectory is not possible.
For recurrent sequence generation, Fragkiadaki et al.
(2015) proposed multilayer LSTM approaches with an encoding and decoding network.
Martinez et al.
(2017), introduced the idea of open loop or ‘sampled’ training (cf.
Bengio et al., 2015) in order to avoid recurrent models converging quickly towards a mean pose.
However, style transfer is unavailable with these methods.
A phase-varying nonlinear autoregressive approach was introduced in Holden et al.
(2017b) which was extended in Mason et al.
(2018) to provide style transfer, but no quantitative results are available.
We are not aware of any existing work which allows style interpolation.
E XPERIMENTS
We investigate the performance of the MTDS on two datasets.
The ﬁrst experiment investigates the performance of the MTDS on synthetic data generated by linear superposition of damped harmonic oscillation (DHO).
The second experiment considers real-world mocap data for human locomotion.
4. D AMPED H ARMONIC O SCILLATION
Data
The generative model for J oscillators with constant amplitudes γ and variable frequency and decay factors, ω ∈ R + , ρ ∈ (0 , 1] is y ( i ) t
= (cid:80)
Jj =1 γ j ( ρ ( i ) j ) t sin( ω ( i ) j t ) + (cid:15)
( i ) t , t = 1 , . .
, 80 for tasks i = 1 , 2 , . .
N .
The emission noise is distributed iid as (cid:15) ( i ) t ∼ N (cid:0) 0 , 0 .
2 (cid:1) and the amplitudes γ =
[1 . 0 , − 0 .
We use J = 2 oscillators with the ‘sequence family’ thus parameterized by a 4-d space.
Details of the generating distribution for ω and ρ are given in supplementary material sec.
A.2.1.
See Figure 2 (a) for example traces.
Model We model the DHO data using an MTLDS with deterministic state X
=
R 4 and a k =latent variable z .
All LDS parameters were adapted via the latent z except D := 0 and the emission variance s 2 , which was learned.
For optimization, we use the MCO algorithm of section A.1.3.
This can obtain a tighter bound than the ELBO, and is useful to investigate convergence to the true model over increasing N .
We contrast this with a bias customization approach (e.g. Miladinovi´c et al., 2019), implemented similarly, but such that only the parameter b (eq. 6) depends on z .
We also train a Pooled LDS, which is the standard approach, using the same parameters for all tasks, and a single-task (STL) LDS which is learned from scratch using Bayesian inference over all parameters for each task.
The Pooled-LDS was initialized using spectral methods (see Van Overschee & De Moor, [Table] and then ﬁne tuned using Adam.
The STL model requires no training as it is inferred directly on test data.
More details are given in section A.2 in the supplementary material.
Evaluation We assess how quickly and effectively the models can adapt to novel test sequences with a training set size of N = 2 1 , 2 2 , . . .
(The STL approach effectively uses N = 0 .)
The test set comprises 20 additional sequences drawn from the generating distribution.
For an initial subsequence y 1: t , we estimate the predictive posterior p ( y t +1: T | y 1: t ) for various t and assess the predictions via root mean squared error (RMSE) and negative log likelihood (NLL).
For MTL we use the Monte Carlo inference method described in supp.
mat.
A.1.5 and for STL we use Hamiltonian Monte Carlo (NUTS, Hoffman & Gelman, 2014).
Each experiment is repeated 10 times to estimate sampling variance.
Results The results, shown in Table 1 and supp.
mat.
section A.2.2, show substantial advantage of using the MTLDS (‘MT Full’) over single-task or pooled approaches.
The MTLDS consistently outperforms the Pooled-LDS for all training sizes N ≥ 4 .
Merely performing bias customization (‘MT Bias’) is insufﬁcient to perform much better than a pooled approach.
An example of MTLDS test time prediction is shown in Figure 2, with Figures 2c and 2d demonstrating effective generalization from the N = 4 training examples (Figure 2a).
Even after 40 observations, the STL approach (which is capable of ﬁtting each sequence exactly) does not signiﬁcantly outperform the N = 4 MTLDS.
Furthermore, the runtime was approx.
1000 times longer since STL inference is higher dimensional and poorly conditioned, and requires a more expensive algorithm.
Note that with a larger training set size of N = 128 , the MLTDS approaches the likelihood of the true model (Figure 7, supp.
mat.).
4. M OCAP D ATA
Data
The dataset consists of 31 sequences from Mason et al.
(2018) (ca. 2000 frames average at 30fps) in 8 styles: angry, childlike, depressed, neutral, old, proud, sexy, strutting.
In this case the family of possible sequences corresponds to differing walking styles.
Each observation represents a 21-joint skeleton in a Lagrangian frame, y t ∈ R 64 where the root movement is represented by a smoothed component and its remainder.
Following Mason et al.
we represent joints by their spatial position rather than their rotation.
We also provide inputs that an animator may wish to control: the root trajectory over the next second, the gait cycle and a boolean value determining whether the skeleton turns around the inside or outside of a corner.
See section A.3.1 in the supplementary materials for more details.
Model We use a recurrent 2-layer base model where the ﬁrst hidden layer is a 1024 unit GRU (Cho et al., 2014) and the second hidden layer is a 128 unit standard RNN, follwed by a linear decoding layer.
The ﬁrst-layer GRU does not vary with z , i.e. it learns a shared representation of the input sequence across all i .
Explicitly, omitting index i , the model for a given z is:
[Equation]
[Equation]
[Figure]
for t = 1 , . . .
, T .
The parameters are θ = { ψ 1 , ψ 2 , H, C, d } where ψ 1 and H are constant wrt.
z .
The matrix H ∈ R (cid:96) × 1024 ( (cid:96) < 1024 ) induces a bottleneck between layers, forcing z to explain more of the variance.
For our experiments, a small (cid:96) can be used (we use (cid:96) = 24 ).
The ﬁrst layer GRU uses 1024 units since it was observed experimentally to produce smoother animations than smaller networks.
The second layer does not use a gated architecture, as gates appear to learn style inference more easily, and result in less use of z .
For learning, each sequence was broken into overlapping segments of length 64 (approx.
two second intervals), which allows z to vary across a sequence.
We learn the model using an open-loop objective, i.e. the y t are not appended to the inputs.
This forces the model to recover from its mistakes as in
Martinez et al.
(2017), although unlike these approaches, we do not append predictions to the inputs either.
Our rationale is that the state captures the same information as the predictions, and while previous approaches required observations y 1: τ as inputs to seed the state, we can use the latent z .
The model was optimized using the variational procedure in section 2.2, where a slower learning rate (by a factor of 10-50) for the ﬁrst layer parameters (i.e. ψ 1 , H ) usually resulted in a more descriptive z .
We also found that standard variational inference for each z
( i ) worked better in general than using amortized inference.
For comparison, we implement a bias customization model (‘MTBias’) via a deterministic state version of Miladinovi ´ c et al., 2019, which follows eqs.
(10)-(13) but only the RNN bias in eq.
(12) is a function of z . We also implement a 1-layer and 2-layer GRU without the multi-task apparatus, which serves both as an ablation test and a competitor model (Martinez et al., 2017) on the new dataset.
Style inference is performed with the same network given an initial seed sequence y 1: τ .
We train these in closed-loop (i.e. traditional next step ‘teacher forcing’ criterion) and open-loop (Martinez et al., 2017) settings.
For baselines, we use constant predictions of ( i ) the training set mean
and ( ii ) the last observed frame of the seed sequence (‘zero-velocity’ prediction).
Experiment 1 We test the data efﬁciency of the MTDS by training the models on subsets of the original dataset.
Besides the models described above, 8 ‘single-task’ versions of the GRU models are trained which only see data for a single style.
We use six training sets of approximate size 2 8 , 2 9 , 2 10 , 2 11 , 2 12 , 2 13 frames per style, where sampling is stratiﬁed carefully across all styles, and major variations thereof.
For all experiments, the model ﬁt (MSE) is calculated from the same 32 held out sequences (each of length 64).
The results are shown in Figure 3a.
As expected, the MTDS, MTBias and Pooled models obtain ‘multi-task’ gains over STL approaches for small datasets.
However, the MTDS demonstrates much greater data efﬁciency, achieving close to the minimum error with only 7% of the dataset.
The MTBias model requires more than twice this amount to obtain the same performance, and the Pooled model requires more than four times this amount.
More details, as with all mocap experiments, can be found in supp.
mat.
section A.2.3.
Experiment
We investigate how well the MTDS can generalize to novel sequence styles via use of a leave-one-out (LOO) setup, similar to transfer learning.
For each test style, a model is trained on the other 7 styles in the training set, and hence encounters novel sequence characteristics at test time.
We average the test error over the LOO folds as well as 32 different starting locations on each test sequence.
The results are given in Figure 3b.
We see that while the competitor (pooled) models perform well initially, they usually degrade quickly (worse for closed-loop models).
In contrast, the multi-task models ﬁnds a better customization which evidences no obvious worsening over the predictive interval.
Unlike pooled-RNNs, the MTDS and MTBias models can ﬁrstly perform correct inference of their customization, and secondly can ‘remember’ it over long intervals.
We note that all models struggle to customize the arms effectively, since their test motions are often entirely novel.
Customization to the legs and trunk is easier since less extrapolation is required (see animation videos linked in section A.4.1).
Experiment
We investigate the control available in the latent z by performing style transfer.
For various inputs U ( s 1 ) from each source style s 1 , we generate predictions from the model using target style s 2 , encoded by z ( s 2 ) .
We use a classiﬁer with multinomial outputs, trained on the 8 styles of the training set, to test whether the target style s 2 can be recognized from the data generated by the
MTDS.
Figure 3c gives the classiﬁer ‘probability’ for each target style s 2 , averaged over all the inputs { U ( s 1 ) : s 1 (cid:54) = s 2 } .
Successful style transfer should result in a the classiﬁer assigning a high probability to the target style.
These results suggest that the prediction style can be well controlled by z ( s 2 ) in the case of the full MTDS, but the MTBias demonstrates reduced control for some (source, target) pairs.
See the videos linked in section A.4.1 for examples, and sec.
A.2.3 for more details.
Qualitative investigation Qualitatively, the MTDS appears to learn a sensible manifold of walking styles, which we assess through visualization of the latent space.
A k = 2 latent embedding can be seen in Figure 4 where the z ( i ) for each training segment i is coloured by the true style label.
Some example motions are plotted in the ﬁgure.
The MTDS embedding broadly respects the style label, but learns a more nuanced representation, splitting some labels into multiple clusters and coalescing others.
These appear broadly valid, e.g. the ‘proud’ style contains both marching and arm-waving, with the latter similar to an arm-waving motion in the ‘childlike’ style.
This highlights the limitation of relying on task labels.
Visualizations such as Fig.
1b indicate that smooth style interpolation is available via interpolation in latent space.
We take advantage of this in the animations (linked from sec.
A.4.1) by morphing styles dynamically.
[Figure]
C ONCLUSION
In this work we have shown how to extend dynamical systems with a general-purpose hierarchical structure for multi-task learning.
Our MTDS framework performs customization at the level of all parameters, not just the biases, and adapts all parameters for general classes of dynamical systems.
We have seen that the latent code can learn a ﬁne-grained embedding of sequence variation and can be used to modulate predictions.
Clearly good predictive performance for sequences requires task inference, whether implicit or explicit.
There are three advantages of making this inference explicit.
Firstly, it enhances control over predictions.
This might be used by animators to control the style of predictions for mocap models, or to express domain knowledge, such as ensuring certain sequences evolve similarly.
Secondly, it can improve generalization from small datasets since task interpolation is available out-of-the-box.
Thirdly, it can be more robust against changes in distribution at test time than a pooled model: standard inference techniques or human supervision can guard against poor performance of the implicit inference
A S UPPLEMENTARY M ATERIAL A. M ODEL
In this section we elaborate on some aspects of the MTDS model which were omitted from the main text.
We discuss the choice of the prior in section A.1.1, give further details of the MTLDS parameterization in section A.1.2, provide an alternative learning algorithm in section A.1.3 (which is especially suited for unsupervised models), and discuss choices of inference algorithm in sections
A.1.4-A.1.5.
A.1. C HOICE OF P RIOR
The usual choice of p ( z ) in latent variable models following Kingma & Welling (2014); Rezende et al.
(2014) is a unit Gaussian p ( z ) =
N ( 0 , I ) .
This choice allows simple sampling schemes, and straight-forward posterior approximations.
It is also a useful choice for interpolation, since it allows continuous deformation of its outputs.
An alternative choice might be a uniform distribution over a compact set, however posterior approximation is more challenging, see Svénsen (1998) for one approach.
Sensible default choices for h φ include afﬁne operators and multilayer perceptrons (MLPs).
However, when the parameter space R d is large, it may be infeasible to predict d outputs from an MLP.
Consider an RNN with 100k parameters.
If an MLP has m L − 1 = 300 units in the ﬁnal hidden layer, the expansion to the RNN parameters in the ﬁnal layer will require 30 × 10 6 parameters alone.
A practical approach is to use a low rank matrix for this transformation, equivalent to adding an extra linear layer of size m L where we must have m L (cid:28) m L − 1 to reduce the parameterization sufﬁciently.
Since we will typically need m L to be O (10) , we are restricting the parameter manifold of θ to lie in a low dimensional subspace.
Since MLP approaches with a large base model will then usually have a restricted ﬁnal layer, are there any advantages over a simple linear-Gaussian model for the prior p ( z ) and h φ ?
There may indeed be many situations where this simpler model is reasonable.
However, we note some advantages of the
MLP approach:
The MLP parameterization can shift the density in parameter space to more appropriate regions via nonlinear transformation.
A linear space of recurrent model parameters can yield highly non-linear changes even to simple dynamical systems (see e.g. the bifurcations in §8 of Strogatz, 2018).
We speculate it might be advantageous to curve the manifold to avoid such phenomena.
More expressive choices may help utilization of the latent space (e.g. Chen et al., 2017).
This may in fact motivate moving beyond a simple MLP for the h φ .
A.1. M ULTI -T ASK L INEAR D YNAMICAL S YSTEM P ARAMETERIZATION
The matrices A , B , R , S of the MTLDS can beneﬁt from speciﬁc parameterizations, which we will discuss in turn.
Degeneracy of LDS.
It will be useful to begin with the well-known over-parameterization of linear dynamical systems.
The hidden dynamics of a LDS can be transformed by any invertible matrix G while retaining the same distribution over the emissions Y .
This follows essentially because the basis used to represent X is arbitrary.
The distribution over Y is unchanged under the following parameter transformations:
[Equation]
Parameterization of A .
The stability constraint,
[Equation]
is equivalent to ensuring that the singular values of A lie within the unit hypercube (since singular values are non-negative).
Let
A =
U Σ V T be the singular value decomposition (SVD) of A .
Now we have from the previous result that if an LDS has latent dynamics with transition parameter A , we may replace the dynamics under the similarity transform G − 1 AG .
Choose G
= U , i.e. the left singular values of A , and hence A = Σ V T U =: Σ Q for some orthogonal matrix Q .
This follows from the closure of the orthogonal group under multiplication, which is easily veriﬁed.
Note that in choosing this transformation, no additional constraints are placed on the other parameters in the LDS.
Orthogonal matrices can be parameterized in a number of ways (see e.g. Khuri et al., 1989).
A straight-forward choice is the Cayley transform .
From Khuri et al.
(1989): “if Q is an orthogonal matrix that does not have the eigenvalue -1, then it may be written in Cayley’s form:
[Equation]
where S is skew-symmetric”.
In order to permit negative eigenvalues, we can pre-multiply by a diagonal matrix E with elements in { +1 , − 1 } .
Since we then have A = Σ EQ , E can be absorbed into Σ , and so the stability constraint (15) can be satisﬁed with the parameterization A = Σ Q where Σ is a diagonal matrix with elements in [ − 1 , +1] and Q is a Cayley-transform of a skew-symmetric matrix.
This follows from the overparameterization of the LDS, and we emphasise that the system equations (4) and (6) are not equivalent, but any LDS distribution over Y can be written with latent dynamics of the form (6).
Parameterization of B .
Choose G
= κ − 1 I in eq.
It may be observed that the scale κ of the latent system can be chosen arbitrarily without affecting A .
We wish to avoid such degeneracies in a hierachical model, since we may otherwise waste statistical strength and computation on learning equivalent representations.
We can remove this by ﬁxing the scale of B .
An indirect but straightforward approach is to upper bound the magnitude of each element of B .
For ˜ B predicted by h φ ( z ) we might choose the transformation B = tanh( ˜ B ) where tanh acts element-wise.
If a sparse B is desired, one can use an over-parameterization of two matrices ˜ B 1 , ˜ B 2 , and choose
B = σ ( ˜ B 1 ) ◦ tanh( ˜ B 2 ) , where ◦ is element-wise multiplication, and σ a logistic sigmoid.
The former parameterization is unlikely to ﬁnd a sparse representation since the gradient of tanh is greatest at 0 .
Parameterization of R , S .
The covariance matrices R , S must be in the positive deﬁnite cone.
Where a diagonal covariance will sufﬁce, any parameterization for enforcing positivity can be used, such as exponentiation, squaring or softplus.
A number of parameterizations are available for full covariance matrices (see Pinheiro & Bates, 1996).
A simple choice is to decompose the matrix, say
R = LL T , where L is a lower triangular Cholseky factor.
As before, it is useful to enforce uniqueness, which can be done by ensuring the diagonal is positive.
A.1. L EARNING VIA A M ONTE C ARLO O BJECTIVE
We provide an alternative learning algorithm to the VB approach in section 2.2 which obtains a tighter lower bound.
This was important for the DHO experiments in order to monitor convergence to the true model.
The below is perhaps a novel approach for learning in unsupervised cases (i.e. where
U = ∅ ), but cannot be performed efﬁciently for supervised problems without modiﬁcation.
Monte Carlo Objectives (MCOs, Mnih & Rezende, 2016) construct a lower bound for marginal likelihoods via a transformation of an appropriate Monte Carlo estimator.
Speciﬁcally we consider the logarithmic transformation of:
[Equation]
m = 1 , . .
, M ; an importance sampling estimator for p ( Y ) .
Using Jensen’s inequality, we show that the following is a lower bound on the log marginal likelihood:
[Equation]
where p ( z 1: M ) :
= p ( z 1 ) ... p ( z M ) .
The tightness of the bound can be increased by increasing the number of samples M (Burda et al., 2016).
Assuming p ( z ) has been re-parameterized
Kingma &
Welling, 2014) to be parameter-free, we can easily calculate the gradient (if not, see Mnih & Rezende, 2016).
By exchanging integration and differentiation, we can calculate the gradient as:
[Equation]
where ˜
w m = p ( Y | z m ) / (cid:80) Mm (cid:48)
=1 p ( Y | z m (cid:48) ) .
Note that eq.
(22) is an importance sampled version of the Fisher identity.
We might expect this estimator to suffer from high variance, since the prior is a poor proposal for the posterior.
However, the prior should not be a poor proposal for the aggregate posterior, i.e.
N (cid:80) Ni =1 p ( z | Y ( i ) )
(see Seth et al., 2017).
In fact, importance sampling from the prior may serve as a useful bias in this case, attracting the posterior distributions which have a large D KL ( p ( z | Y ( i ) )
|| p ( z )) towards the prior.
Our observation is that sampling from the prior can be amortized over each sequence Y ( i ) , i = 1 , . . .
, N .
Speciﬁcally, for each particle z m , the dynamics (2), (3) can be run forward once to calculate ˆ
Y m , from which the likelihood Y ( i ) , for all tasks i = 1 , . .
. , N can be calculated inexpensively.
The amortized cost of taking M samples (e.g. M ∈ O (10 3 ) ) now becomes M/N , which may be relatively small.
We can also take advantage of low-discrepancy random variates such as Sobol sequences (Lemieux, 2009) to reduce variance.
We propose that each sequence i resamples a small number
M rsmp ≤ 5 of particles from the importance weights for each i to reduce the cost of backpropagation (a similar resampling scheme is suggested in Burda et al., 2016).
See Algorithm 1.
In the supervised case (i.e. where each observation Y ( i ) has a different input U ( i ) ), running the dynamics forward from a particle z m can no longer be amortized over all { Y ( i ) } since the prediction ˆ Y ( i ) depends on U ( i ) .
We can therefore only amortize the parameter generation θ =
h φ ( z ) , which is often less expensive than running the dynamics forward.
For this reason Algorithm 1 is primarily restricted to unsupervised problems.
A hybrid approach would essentially result in the importance weighted autoencoder (IWAE) of Burda et al.
A.1. I NFERENCE
Inference at test time can be performed by any number of variational or Monte Carlo approaches.
As in the main text, our focus here is on deterministic state dynamical systems.
For stochastic state models, additional reasoning similar to Miladinovi´c et al.
(2019) will be required.
A gold standard of inference over z may be the No U-Turn Sampler (NUTS) of Hoffman & Gelman (2014) (a form of Hamiltonian Monte Carlo), provided k is not too large and efﬁciency is not a concern.
However, given the sequential nature of the model, it is natural to consider exploiting the posterior at time t for calculating the posterior at time t + 1 .
Bayes’ rule suggests an update of the Result:
Optimized parameter ˆ φ
Inputs : { Y ( i ) } Ni =1 , φ , M, M rsmp , nepochs , optimizer; for epoch
= 1:nepochs do for minibatch S in { 1 , . . .
, N } do // calculate posterior samples;
z m [Equation]
p ( z )
[Equation]
m
[Equation]
, M ;
W ← construct _ weights (cid:0)
[Equation]
[Equation]
[Equation]
[Equation]
=
[Equation]
, { Y ( i )
[Equation]
i ∈
[Equation]
(cid:1) ; // compute gradient; g ← 0 ; for i in S do for m in { 1 , . . .
, M rsmp } do i ∼ Categorical (cid:0) W ( i ) (cid:1) ;
[Equation]
end end
Optimize ( optimizer , φ , g ) ; end end following form:
[Equation]
[Equation]
following the conditional independence assumptions of the MTDS.
This update (in principle) incorporates the information learned at time t in an optimal way, and further suggests a constant time update wrt t .
However, evaluation of p ( y (cid:48) t +1 | u (cid:48) 1: t +1 , h φ ( z )) usually scales linearly with t , since the state x t +1 must be calculated recursively from x 0 given z and u (cid:48) 1: t +1 .
Nevertheless, sequential incorporation of previous information will perform a kind of annealing (Chopin, 2002) which reduces the difﬁculty, and hopefully the runtime of inference at each stage.
We ﬁrst provide some background of the difﬁculties of such an approach, looking ﬁrst at Monte Carlo (MC) methods.
Naïve application of Sequential Monte Carlo (SMC) will result in severe particle depletion over time.
To see this, let the posterior after time t be p ( z | y (cid:48) 1: t , u (cid:48) 1: t )
=
1 M (cid:80) Mm =
1 w m δ ( z − z m ) .
Then the updated posterior at time t + 1 will be:
[Equation]
where ˜ w m = w
[Equation]
p
[Equation]
| u
[Equation] φ [Equation] j )) , simply a re-weighting of existing particles.
Over time, the number of particles with signiﬁcant weights w m will substantially reduce.
But since the model is static with respect to z (see Chopin, 2002), there is no dynamic process to ‘jitter’ the { z m } as in a typical particle ﬁlter, and hence a resampling step cannot improve diversity.
Chopin (2002) discusses two related solutions: ﬁrstly using ‘rejuvenation steps’ (cf.
Gilks & Berzuini, 2001) which applies a Markov transition kernel to each particle.
The downside to this approach is the requirement to run until convergence; and the diagnosis thereof, which can result in substantial extra computation.
One might instead sample from a ﬁxed proposal distribution (accepting a move with the usual Metropolis-Hastings probability) for which convergence is more easily monitored.
A
Sequential Monte Carlo sampler approach (Del Moral et al., 2006) may be preferred, which permits local moves, and can reduce sample impoverishment via resampling (similar to SMC).
However, the approach requires careful choices of both forward and backward Markov kernels which substantially reduces its ease of use.
A well-known variational approach to problems with the structure of eq.
(23) is assumed density ﬁltering (ADF, see e.g. Opper & Winther, 1998).
For each t , ADF performs the Bayesian update and the projects the posterior into a parametric family Q .
The projection is done with respect to the reverse KL Divergence,
i.e. q t +1 = arg
min q ∈Q D KL (cid:0) p ( z | y (cid:48) 1: t +1 , u (cid:48) 1: t +1 )
|| q (cid:1) .
Intuitively, the projection ﬁnds an ‘outer approximation’ of the true posterior, avoiding the ‘mode seeking’ behaviour of the forward KL, which is particularly problematic if it attaches to the wrong mode.
Clearly the performance of ADF depends crucially on the choice of Q .
Unfortunately, where Q is expressive enough to capture a good approximation, the optimization problem will usually be challenging, and must resort to stochastic gradient approaches, resulting in an expensive inner loop.
Furthermore, when the changes from q t to q t +1 are relatively small, the gradient signal will be weak, resulting perhaps in misdiagnosed convergence and hence accumulation of error over increasing t .
A recent suggestion of Tomasetti et al.
(2019) is to improve efﬁciency via re-use of previous (stale) gradient evaluations.
Standard variance reduction techniques may also be considered to improve convergence in the inner loop.
A.1. O NLINE I NFERENCE – OUR APPROACH
In our experiments, we found sampling approaches faster and more reliable for each update, as well as providing diagnostic information, and so we eschew variational approaches.
(Our experiments used a fairly small k ( ≤ 10 ); variational approaches may be preferred in higher dimensional problems.)
Speciﬁcally we use iterated importance sampling (IS) to update the posterior at each t .
The key quantity for IS is the proposal distribution q prop : we need a proposal that is well-matched to the target distribution.
Our observation is that the natural annealing properties of the ﬁltering distributions (eq.
23) allow a slow and reliable adaptation of q prop .
In order to capture complex multimodal posteriors, we parameterize q prop by a mixture of Gaussians (MoG).
For each t , the proposal distribution is improved over N AIS iterations using adaptive importance sampling (AdaIS), described for mixture models in Cappé et al.
We brieﬂy review the methodology for a target distribution p ∗ .
Let the AdaIS procedure at the n th iteration use the proposal:
[Equation]
26) α j ∈ R + s.t.
{+(cid:80) Jj =
 α j = 1 . For iteration n , sample z m ∼ q n − 1 prop , m = 1 , . . .+}
, M , and calculate the (self-normalized) importance weights ˜
w m ∝ p ∗ ( z m ) /q
n − 1 prop ( z m ) .
The resulting empirical distribution is then used to ﬁt q n +1 prop , estimating { α n +1 j , µ n + [Equation] , Σ n + [Equation]
} Jj =1 via (weighted) Expectation
Maximization (EM, see Cappé et al., 2008, for details).
We monitor the effective sample size (ESS, see ch.
9, Owen, 2013)
every iteration and stop once the ESS has reached a certain threshold M ess , see Algorithm 2.
For our experiments, this approach worked robustly and efﬁciently, and appears superior to the alternatives discussed.
Unlike SMC, we obtain a q prop which is a good parameteric approximation of the true posterior.
We therefore avoid the sample impoverishment problem discussed above (eq.
Due to the small number of iterations of AdaIS required (usually ≤ 5 for our problems), it is substantially faster than MCMC moves, and since stochastic gradients are avoided, convergence is much faster than variational approaches.
The scheme beneﬁts from the observed fast initial convergence rates of the EM algorithm (see e.g. Xu & Jordan, 1996), particularly since early stopping can be used for the initial iterates.
In practice, one may not wish to calculate a posterior at every t , but instead intervals of length τ .
In our DHO experiments ( k = 4 ) we use τ = 5 , and usually have ESS > 0 .
6 M after n =inner iterations, with total computation per q t requiring 250-300ms on a laptop.
We observe in our experiments that posteriors are often multimodal for t ≤ 20 and sometimes beyond, motivating the
MoG parameterization.
In these experiments, the MoG appears to capture the salient characteristics of the target distribution well.
Note as in section A.1.3, Sobol or other low-discrepancy sequences may be used to reduce sampling variance from q prop .
Result: Approximate posteriors { q t } Tt =
Inputs : y 1: T , u 1: T , φ , M, M ess , N AIS , J ; q 0 ← p ( z ) ; for t = 1 : T do ess ← 0 ; q 0 prop ← q t − 1 ; for n = 1 : N AIS do for m = 1:M do z m ∼ q n − 1 prop ; w m ← p ( y 1: t | u 1: t , h φ ( z m ))
p ( z ) q n − 1 prop ( z m ) ; end ˜
w m ← w m (cid:80) M(cid:96)
=1 w (cid:96) , m = 1 , . . .
, M ; q n prop ← WeightedExpectationMaximization (cid:0) { z m } Mm =1 , { ˜
w m } Mm =1 , J ; init =
q n − 1 prop (cid:1) ; ess ← EffectiveSampleSize (cid:0) {
˜ w m } Mm =1 (cid:1) ; if ess > M ess then break; end end q t ← q n prop end
A. D AMPED H ARMONIC O SCILLATION
This section provides further details about the damped harmonic oscillator (DHO) experiments: the data, experimental setup and results.
A.2. D ATA
We generate data via the model:
[Equation]
(27) t = 1 , . .
80 which is the sum of two damped harmonic oscillators each with angular frequency ω j and decay factor ρ j ∈ (0 , 1] for tasks i
= 1 , 2 , . .
N .
The data are corrupted by iid Gaussian noise, (cid:15) ( i ) t ∼ N (cid:0) 0 , 0 .
2 (cid:1) .
The distribution over the random variables is given in Figure 5c.
We choose the second component to be (in expectation) a higher frequency, faster decaying component.
A visualization of these distributions is provided in Figures 5a-5b.
The distributions were chosen to achieve good visual diversity of sequences.
It is natural to parameterize ρ j by its half-life (i.e. t such that ρ tj = 0 . 5 ), since interesting decay factors are concentrated near 1.
For instance, ρ j = 0 .
98 results in a half-life of ν ≈ 34 , and ρ j = 0 .results in a half-life of ν ≈ 69 .
To generate a decay factor, we sample a half life ν in a relevant interval (Table 5c) and, using the deﬁnition of half life, transform via ρ = exp {− log(2) /ν } .
A.2. E XPERIMENTAL SETUP
Parameterization.
We use the model:
[Equation]
1.5    1(a) 0.
1.00    1(b) ω
U [1 . 5 2 π 80 , 6 2 π 80 ] ρ 1 half-life
U [4 , 80] ω
U [5 2 π 80 , 8 2 π 80 ] ρ 2 half-life
U [8 , 60] (c)
[Figure]
for t = 1 , . . .
, T , z ∈ R 4 , x t ∈ R 4 , suppressing task index i for clarity.
Deﬁne x 0 := 0 , and for all tasks u
=
A is parameterized as discussed in section A.1.2 using a product of a diagonal and orthogonal matrix Σ Q .
The diagonal of Σ is constrained to lie in [ − 1 , +1] using the tanh function, and Q is parameterized by the Cayley transform of a skew symmetric matrix S .
Using an upper triangular matrix Γ , we have S =
Γ − Γ T , and Q
=
( I − S )
( I + S ) − 1 .
We parameterize B via the product of logistic sigmoid and tanh functions as in section A.1.2 in order to learn a sparse parameterization.
C is unconstrained, and the parameter s is optimized as a constant wrt.
z .
The
STLDS is parameterized in the same way.
The prior p ( z ) is a unit Gaussian distribution, and h φ is a 2 hidden-layer neural network.
We use a ﬁxed feature extractor z
→
[ z T , sin( z T ) , cos( z T ) , (cid:107) z (cid:107) ]
T in the ﬁrst layer in order to help encode a rectangular support within a spherically symmetric distribution.
The second layer is a fully-connected 300 unit layer with sigmoid activations.
Learning.
The output of an MTLDS is very sensitive to the parameter A , and care must be taken to avoid divergence during optimization.
The diagonal-orthogonal parameterization greatly helped to stabilize the optimization over a more naïve orthogonal-diagonal-orthogonal SVD parameterization.
We also reduced the learning rate by a factor of 10 for A .
It proved useful to artiﬁcially elevate the estimate of s during training using a prior log s ∼ N ( − 1 . 5 , 0 . 05)
(derived from preliminary experiments) since the MTDS can otherwise overﬁt small datasets (see also discussion in §3, Svénsen, 1998), with associated instability in optimization.
The learning rate schedule is given in Table 2, for which the prior over log s ∼ N ( m, 0 . 05) was annealed from m = − 1 . 0 to m = − 1 . 5 .
The “momentum” parameter β 1 (c.f. Kingma & Ba, 2014) is also reduced at the end of optimization.
The latter was motivated by oscillation and moderate deviations observed near optima, apparently caused (upon investigation) by strong curvature of the loss surface.
Inference.
The latent z are inferred online using the adaptive IS scheme of section A.1.5.
We also perform inference over log s since it is held artiﬁcially high for optimization, and its true optimal value is not known.
An informative prior close to the learned value log s ∼ N (cid:0) − 2 . 0 , 0 .
1 2 (cid:1) , was
[Table] [Table]
nevertheless used since the posterior was sometimes approximately singular, causing high condition numbers in the estimated covariance matrix of the proposal.
The hyperparameters are given in Table 3.
These parameters did not require tuning as for optimization, but were sensible defaults.
These also seem to work well without tuning for other experiments such as the Mocap data.
Each posterior for a given time t took on average approx.
3 seconds.
We used the No U-Turn Sampler (Hoffman & Gelman, 2014) for the STL experiments due to poor conditioning and the higher complexity and dimensionality of the posterior (19 dimensions).
Tuning is performed using ideas from Hoffman & Gelman (2014, Algorithm 4, 5)
[Table]
and the mass matrix is estimated from the warmup phase.
The warmup stage lasted 1000 samples and the subsequent 600 samples were used for inference.
Each sampler was initialized from a MAP value, obtained via optimization with 10 random restarts.
For both MAP optimization and sampling, we found it essential to enforce a low standard deviation (we used log s = − 2 and log s ∼ N (cid:0) − 2 , 0 .
2 2 (cid:1) respectively) similarly to the MTL experiments.
The autocorrelation-based effective sample size (Gelman et al., 2013, ch. 11.5) typically exceeds 100 for each parameter.
Each posterior for a given time t took on average approx.
300 seconds.
Note that as discussed in section A.1.4, unlike our AdaIS procedure, we cannot make much re-use of previous computation here.
A.2. R ESULTS
The average results (over the 10 repetitions) are given in Table 4, which extends Table 1 in the main text with the NLL results.
The distribution of these results can be seen in the violin plots of Figure 8.
The RMSE results of the MTLDS are all signiﬁcantly better than both the pooled and single-task models according to a Welch’s t-test and Mann-Whitney U-test, except for MTLDS-4 at t = 40 .
The latter is signiﬁcantly better than the pooled model, but is indistinguishable from the STLDS at the level α = 0 .
We also consider the convergence of the MTLDS to the true model with increasing N .
For each experiment, we average the log marginal likelihood of the test sequences estimated via 10 000 (Sobol) samples from the prior.
As before, the prior should be a good proposal for the aggregate posterior, and we amortize the same samples over all test sequences.
In order to interpret the difference to the true distribution log p ∗ ( Y test ) − log p
( Y test | φ ) , we use the Bayes Factor interpretations given by Kass
[Table]
[Figure]
& Raftery (1995).
For instance a difference of 1.0 is ‘barely worth mentioning’, but a difference of 4.0 is ‘strong evidence’ that the distributions are different.
We average over 10 000 test examples to avoid sampling variation of the test set.
Figure 7 show boxplots of the log marginal likelihood for each model over increasing N , where the boxes show the interquartile range (IQR) over therepetitions.
We see convergence towards the true value with increasing N , with the difference of the
MTLDS-128 ‘barely worth mentioning’.
[Figure] [Figure]
[Figure]
A. H UMAN L OCOMOTION M OTION C APTURE (M OCAP ) E XPERIMENTS
We provide further details about the data, experimental setup and results of the human locomotion experiments below.
A.3. H UMAN L OCOMOTION M OTION C APTURE (M OCAP )
The mocap data of Mason et al.
(2018) consists of planar walking and running motion in 8 styles.
The original data is recorded at 120 fps, we downsample to 30 fps as per Martinez et al.
; Pavllo et al.
Unlike Mason et al.
(2018), we do not perform any data augmentation via mirroring.
The data is mapped to a 21-joint skeleton used in the codebase of Holden et al.
(2016), shown in
Figure 9a, which is a subset of the CMU skeleton.
Representation in observation space.
We choose a Lagrangian representation (Figure 9c) where the coordinate frame is centered at the root joint of the skeleton (joint 1 in Fig.
9a, the pelvis), projected onto the ground.
The frame is rotated such that the z -axis points in the “forward” direction, roughly normal to the body.
This is in contrast to the Eulerian frame (Figure 9b) which has an absolute ﬁxed position for all t .
In the Lagrangian frame, the joint positions are always relative to the root joint, which avoids confusing the overall trajectory of the skeleton (typiﬁed by the root joint), and the overall rotation of the skeleton, with the local motions of the joints.
The relative joint positions can be represented by spatial position or by joint angle.
For the latter, the spatial positions of all joints can be recovered from the angle made with their parent joint via use of forward kinematics (FK).
This construction ensures the constant bone length of the skeleton over time, which is a desirable property.
However, it also substantially increases the sensitivity of internal joints.
For instance, the rotation of the trunk will disproportionately affect the error of the joints in both arms.
For this reason, we have chosen to model the spatial position of joints, which may result in violations of bone length, but avoids these sensitivity issues.
See also §2.1 Pavllo et al.
One can further encode the joint positions via velocity (i.e. differencing) which may result in smoother predictions.
We avoid this encoding for the local joint motion (joints 2 to 21) since it can suffer from accumulated errors, but we do use it to predict the co-ordinate frame as is standard in mocap models.
Hence our per-frame representation consists of the velocity ˙ x, ˙ z, ˙ ω of the co-ordinate frame, the relative vertical position of the root joint, and 3-d position of the remaining 20 joints, which gives y t ∈ R 64 .
Choice of inputs.
Our choice of inputs will reﬂect controls that an animator may wish to manipulate.
The ﬁrst input will be the trajectory that the skeleton is to follow.
As in Holden et al.
(2017b), we provide the trajectory over the next second (30 frames), sampled uniformly every 5 frames.
Unlike previous work, there is no trajectory history in the inputs since this can be kept in the recurrent state.
The (2-d) trajectory co-ordinates are given wrt.
the current co-ordinate frame, and hence can rotate rapidly during a tight corner.
In order to provide some continuity in the inputs, we also provide a ﬁrst difference of the trajectory in Eulerian co-ordinates.
[Table]
The velocity implied by the differenced trajectory does not disambiguate the gait frequency vs. stride length.
The same motion might be achieved with fast short steps, or slower long strides.
We therefore provide the gait frequency via a phasor (as in Holden et al., 2017b), whose frequency may be externally controlled.
This is provided by sine and cosine components to avoid the discontinuity at 2 π .
A ﬁnal ambiguity exists from the trajectory at tight corners: the skeleton can rotate either towards the focus of the corner, or towards the outside.
Figure 9d demonstrates the latter, which appears not infrequently in the data.
We provide a boolean indicator alongside the trajectory which identiﬁes corners for which this happens.
Altogether we have u t ∈ R 32 : 12 inputs for the Lagrangian trajectory, 12 inputs for the differenced Eulerian trajectory, 2 inputs for the gait phase and 6 inputs for the turning indicators.
Extracting the root trajectory.
The root trajectory is computed by projecting the root joint onto the ground.
However, this projection may still contain information about the style of locomotion, for instance via swaying.
We wish to remove all such information, since a model can otherwise learn the style without reference to a latent z .
Our goal is to ﬁnd an appropriately smoothed version of the extracted trajectory T .
We use a cubic B-spline ﬁt to control points ﬁtted to the ‘corners’ of the trajectory.
These control points are selected using a polygonal approximation to T using the
Ramer-Douglas-Peucker algorithm (RDP, e.g. Ramer, 1972).
Brieﬂy, the RDP algorithm uses a divide-and-conquer approach which greedily chooses points that minimize the Hausdorff distance of
T to the polygonal approximation.
Some per-style tuning of the RDP parameter, and a small number of manually added control points rendered this a semi-automatic process.
Extracting the gait phase.
Foot contacts are calculated via the code used by Holden et al.
(2017b), which is based on thresholding of vertical position and velocity of each foot.
As in Mason et al.
we check visually for outliers and correct misclassiﬁed foot contacts manually.
The leading edge of each foot contact is taken to represent 0 (left) and π (right), and the gait phase is calculated by interpolation.
A.3. E XPERIMENTAL SETUP
In this section we discuss elements of the experimental setup, learning and inference common to all experiments.
Details particular to each experiment can be found in the following section.
Further Model Details
The MTDS architecture is described in section A.3, aside from the choice of prior.
We tested both linear and nonlinear h φ in preliminary experiments and the performance was often similar.
The nonlinear version used a one hidden layer MLP with 300 hidden units with tanh activations.
For the ﬁnal afﬁne layer, we used a rank 30 matrix which, chosen pragmatically as a trade-off between ﬂexibility and parameter count (see discussion in section A.1.1).
Both choices often performed similarly, however the linear approach was chosen, since optimization of the latent z on new data was faster, and apparently more robust to choice of initialization.
A nonlinear h φ may be more important when the base model is simpler.
The benchmark models use an encoding length of τ = 64 frames.
The encoder shares parameters with the decoder, i.e. the RNN is simply ‘warm started’ for 64 frames before prediction.
The benchmark models, unlike the MTDS, predict the difference from the previous frame (or ‘velocity’) via a residual architecture, as this performs better in Martinez et al.
Further Learning Details Our primary goal was qualitative: to obtain good style-content separation, high quality animations and smooth interpolation between sequences.
Therefore hyperparameter selection for the MTDS proceeded via quantitative means (via the ELBO) and visual inspection of the qualitative criteria.
The qualitative desiderata motivated split learning rates between shared and multi-task networks (cf.
section 4.2), and the amount of L2 regularization.
See Table 5 for the chosen values.
The main learning rate η applies to the ﬁxed parameters wrt.
z (i.e. ψ 1 , H ), and the multi-task learning rate applies to the parameter generation parameters φ and inference parameters λ .
Standard variational inference proved more reliable than amortized inference: we used a Gaussian with diagonal covariance (parameterized using softplus) for the variational posterior over each z .
L regularization was applied to φ , ψ 1 , H .
Unless otherwise speciﬁed, we optimized each model using a batch size N batch = 16 for 20iterations.
The ELBO had often reached a plateau by this time, and training even longer resulted in a worse latent representation at times (as evidenced through poor style transfer).
As noted in the main text, we remove the KL penalty of eq.
(9) for the initial 2 000 iterations, and enforce a small posterior standard deviation ( s λ = 10 − 3 ) for the same duration.
This is similar to ﬁnding a MAP estimate for the { z } .
For the remaining iterations, the original ELBO criterion is used, and the constraint on s λ is removed.
The model is implemented in PyTorch (Paszke et al., 2017) and trained on GPUs.
Since we use a fairly small max.
sequence length L = 64 , truncated backpropagation through time was not necessary.
The hyper-parameters for the benchmark models were found (Table 5) using a grid search over learning rate and regularization, as well as the optimizers {Adam, (vanilla) SGD}.
We performed the search over the pooled data for all 8 styles, with a stratiﬁed sample of 12.5% held out for a validation set.
Once the hyperparameters were chosen, benchmark models were also trained for 20 000 iterations, recording the validation error every 1 000 iterations on a stratiﬁed 12.5% held out sample.
The model with the lowest validation error during optimization is chosen.
We standardize the data so that when pooled, each dimension has zero mean and unit variance.
Finally, note that as discussed in section A.3.1, the data are represented in Lagrangian form, therefore drifts in the predicted trajectory from the true one are not necessarily heavily penalized.
This can be altered by changing the weights on the root velocities, but we did not do this.
Inference.
At test time, especially for experiment 2, we cannot expect amortized inference to perform optimally, and we consider standard inference techniques.
We want to understand the nature of the posterior distributions, and so we again used the AdaIS approach of section A.1.5.
In practice, each posterior was unimodal and approximately Gaussian.
Furthermore, the variation in sequence space for different z in the posterior was usually fairly small, and the posterior predictive mean performed similarly to using a point estimate.
Each observation from which z is inferred is of size 64 × 64 and hence the posterior is fairly concentrated.
Unlike the DHO model, this is a more expensive procedure.
Our k = 3 experiments took approx.
24 seconds per observation for inference.
An optimization approach using standard techniques may be expected to perform similarly at a reduced computational cost.
Hence unless otherwise speciﬁed, inference was done via optimization.
A. E XPERIMENTS
Experiment 1 – MTL The training data for each style uses 4 subsequences chosen carefully to represent the inter-style variation.
Obviously it is important that frames are consecutive rather than randomly sampled.
Over the increasing size training sets, each of these subsequences is a superset of the previous one.
The 6 training set sizes ( 2 8 , 2 9 , 2 10 , 2 11 , 2 12 , 2 13 frames per style) are not exact since short subsequences are discarded (e.g. at ﬁle boundaries), and the largest set contains all the training data except the test set 3 , where data are not evenly distributed over styles.
The test set comprises 4 sequences from each style, each of length 64, and is the same for all experiments.
A length-64 seed sequence immediately preceding each test sequence was used for inference for all models.
The models are trained as described above, except for the single task (STL) models.
The STL models use an identical architecture to the pooled 1-layer GRU models, except they are trained only on the data for their style.
Since there is less data for these models, we train them for a
[Table]
maximum of 5 000 iterations.
We do not train 2-layer GRUs, since the amount of data is small for most experiments
The full results are given in Table 6.
We use fractions of the dataset instead of absolute training set sizes to aid understanding.
The performance of the MTDS appears to increase with larger k , and suggests that we need k > 3 to achieve optimal performance on unseen training data.
The results demonstrate substantial beneﬁt of the MTDS over a pooled RNN model in terms of sample efﬁciency, but not in asymptotic performance, as might be expected.
According to a paired t-test, the improvements of the k = 7 MTDS over the (1-layer, open loop) pooled GRU are signiﬁcant for training set sizes 3% , 7% , 13% and 27% .
At a style level, the k = 7 MTDS performs at least as well as the pooled GRUs for the ﬁrst four training set sizes.
See Figure 10.
Note that the ‘angry’ and ‘childlike’ styles appear to be harder than the others, most likely due to their relatively high speed.
For example animations of the MTL experiments, see the linked video in section A.4.1.
Experiment 2 – Novel Sequences Table 7 provides the aggregate results of experiment 2 for each of the mocap models.
A visualization is given in Figure 11.
The 2-layer competitors are shown here for completeness, but they achieve similar performance to the 1-layer models on aggregate.
Figure 12 provides a breakdown of these results on a per-style basis.
Styles 5-8 appear to be easier from the point of view of the benchmarks, but the MTDS shows equal or better performance on all styles except style 5.
The competitor results achieve better short-term performance than the MTDS.
However, note that the zero-velocity baseline performs similarly to the open-loop GRUs for the ﬁrst 5 predictions.
This suggests that the MTDS may be improved for these early predictions simply by interpolating from the zero-velocity baseline for small values of t .
We are unable to conclude from these experiments that the benchmark models can represent the style better initially, but simply that they can smooth the transition from the seed sequence better.
Experiment 3 – Style Transfer The classiﬁer is learned on the original observations to distinguish between the 8 styles.
We use a 512-unit GRU to encode an observation sequence (usually offrames), and transform the ﬁnal state via a 300-unit hidden layer MLP with sigmoid activations into multinomial emissions.
The model is trained via cross-entropy with 20% of the training data held out as a validation set; training was stopped as the validation error approached 0.
We perform a standardization of the gait frequency across all styles, since some styles can be identiﬁed purely by calculating the frequency.
The mean frequency across all styles (1 cycle per 33 frames) is applied to all sequences via linear interpolation.
In this we make use of the instantaneous phase given in the inputs.
We use a k = 8 latent code for the MTDS as the model is trained on all styles.
[Figure]
[Table] [Table] [Figure] [Figure]
[Figure]
(b) The experimental setup is as follows.
We carefully choose four segments of length 64 for each of the styles s 1 = 1 , . . .
, 8 which represent the variability within each style.
These correspond to the inputs U ( s 1 ) j for each source style s 1 , with examples j = 1 , . . We next seek the ‘archetypal‘ latent code z associated with each target style s 2 . For each s 2 , we optimize z over 20 candidate values, obtained from the posterior mean of the style s 2 in the training set.
Data are generated from all { U ( s 1 ) j } and the z which provides the greatest success in style transfer is chosen.
The 32 highly varied input sequences guard against overﬁtting – the ‘archetypal’ codes for each style must perform well across much of the variety of the original dataset.
We provide a scalar measurement of the ‘success’ of style transfer for each pair ( s 1 , s 2 ) by using the resulting ‘probability’ that the classiﬁer assigns the target style s 2 , averaged across the four input sequences for the source s 1 .
The results of these experiments are shown in Figure 13a for the model with multi-task bias, and
Figure 13b shows the results for the full MTDS.
Table 3c in the main text gives the marginal of these results wrt.
the target style.
The cells in Figure 13 give the classiﬁer probability for the target style for each (source, target) combination, averaged over the four source inputs. Successful style transfer should result in a the classiﬁer assigning a high score in every cell of the table.
For most (source, target) pairs, the full MTDS model substantially outperforms the MTBias model: it appears that MTDS can control the prediction well in the majority of cases, and the MTBias model offers reduced control in general.
However, we observe for both models that it is more difﬁcult when styles are associated with extremes of the input distribution.
Speciﬁcally, both the ‘childlike’ and ‘angry’ styles have unusually high speed inputs, and the ‘old’ style has unusually low speeds.
Note that in order to provide style transfer, the models are mostly ignoring these correlations, even though they are very useful for prediction.
Further improvements may be available, perhaps by using an adversarial loss, or applying domain knowledge to the model.
This is orthogonal to our contribution, and we leave this to future work.
Providing style transfer from all varieties of source style is a challenging task.
For instance, some styles include sources with widely varying speeds and actions, which may be mismatched to the target style. To understand what may be more typical use of the model, we provide an easier variant of this experiment where only one example of each source style is provided, rather than four. Note nevertheless that the same z ( s 2 ) is still used across all sources s 1 . The results of this secondary experiment are provided in Figure 14.
In this case, style transfer is successful for almost all (source, target) pairs in the case of the MTDS, except for the angry style.
The MTBias model still has many notable failures.
[Figure]
(b)
A.4. G ENERATED A NIMATIONS
A selection of animations are available online.
We provide a link and a brief description of each set below.
Where applicable, the animations show a comparison between the ground truth, the relevant
MTDS model, and the (1 layer, open loop) pooled-GRU model.
The latter was chosen by virtue of being the best competitor model in all experiments.
In all cases, animations are a complete predictive rollout with no access to the ground truth.
In-sample predictions https://vimeo.com/362069486.
The goal is to showcase the best possible performance of the models by predicting from inputs in the training set.
MTL examples https://vimeo.com/362122944.
Examples from Experiment 1.
We compare the quality of animations and ﬁt to the ground truth for two limited training set sizes (6.7% and 13.3% of the full data).
For both models, MSE to the ground truth is given, averaged over the entire predictive window (length 256).
This is different to the experimental setup which uses only the ﬁrst 64 frames.
Novel test examples https://vimeo.com/362068342.
Examples from Experiment 2.
We show the adaptions obtained by each model to novel sequences, in particular showcasing examples of the pooled GRU models inferring suboptimal styles wrt.
MSE.
Again, MSE to the ground truth is given averaged over the predictive window (length 256).
Style morphing https://vimeo.com/361910646.
This animation demonstrates the effect of changing the latent code over time.
This also demonstrates style transfer and style interpolation from experiment 3.
For style morphing, we found it useful to ﬁx the dynamical bias of the second layer (parameter b in eq. 7) wrt.
z since it otherwise resulted in ‘jumps’ while interpolating between sequences.
We speculate that shifting the bias induces bifurcations in the state space, whereas adapting the transition matrix allows for smooth interpolation.