{'fraction_non_alphanumeric': 0.0503447984092736, 'fraction_numerical': 0.011084316960697211, 'mean_word_length': 4.766772383508172, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
PlaNet of the Bayesians: Reconsidering and Improving Deep Planning Network by Incorporating Bayesian Inference

In the present paper, we propose an extension of the Deep Planning Network (PlaNet), also referred to as PlaNet of the Bayesians (PlaNet-Bayes). There has been a growing demand in model predictive control (MPC) in partially observable environments in which complete information is unavailable because of, for example, lack of expensive sensors. PlaNet is a promising solution to realize such latent MPC, as it is used to train state-space models via model-based reinforcement learning (MBRL) and to conduct planning in the latent space. However, recent state-of-the-art strategies mentioned in MBRR literature, such as involving uncertainty into training and planning, have not been considered, significantly suppressing the training performance. The proposed extension is to make PlaNet uncertainty-aware on the basis of Bayesian inference, in which both model and action uncertainty are incorporated. Uncertainty in latent models is represented using a neural network ensemble to approximately infer model posteriors. The ensemble of optimal action candidates is also employed to capture multimodal uncertainty in the optimality. The concept of the action ensemble relies on a general variational inference MPC (VI-MPC) framework and its instance, probabilistic action ensemble with trajectory sampling (PaETS). In this paper, we extend VI-MPC and PaETS, which have been originally introduced in previous literature, to address partially observable cases. We experimentally compare the performances on continuous control tasks, and conclude that our method can consistently improve the asymptotic performance compared with PlaNet.


I. INTRODUCTION
In the present paper, we focus on model predictive control (MPC) in partially observable environments. MPC is a promising technique used in advanced control systems that relies on the specified system models to predict future states and rewards for the purpose of planning. The clear explainability of such decision-making processes is preferable, especially for industrial systems, and therefore, many real-world applications have introduced MPC such as HVAC systems [1], manufacturing processes [2], and power electronics [3]. The above systems assume fully observable environments; however, in practical applications, complete information is often unavailable, as measuring sufficient information for planning may be difficult and/or require expensive devices (for example, LiDARs).
The Deep Planning Network (PlaNet) [4] is an MPCoriented model-based reinforcement learning (MBRL) method used for partially observable environments.  outlines the concept of PlaNet in which an encoder is utilized to convert partial observations x t (e.g., high-dimensional raw observations such as images) into latent states z t . In the latent space, a prediction model is used to estimates next latent states z t+1 and rewardsr t based on current states z t and given actions a t . This modeling way allows planning in the latent state-space in which we expect that the sufficient information for planning is embedded. As our primary interest is to apply MPC to practical systems, in this paper, we mainly focus on PlaNet and consider this method as a strong baseline.
Recent studies on MBRL in fully observable environments have shown that uncertainty-aware modeling is essential to enhance the training performance. The model-bias problem [5], which occurs because of the overfitting of model parameters θ with respect to the limited amount of data D available during an early training phase, has been regarded as an inherent problem that restrains the MBRL potential. However, recent studies have demonstrated that incorporating uncertainty in the model parameters can alleviate this issue by exploiting Bayesian inference of posterior p(θ|D) [5]- [13]. In addition, in [12], they have shown that involving uncertainty in optimal actions also affects performance improvement. In the literature, the trajectory optimization problem in the Markov decision process is formulated as a variational inference problem [14], deriving a general framework called variational inference MPC (VI-MPC). As an instance of the framework, probabilistic action ensemble with trajectory sampling (PaETS) is also proposed that uses Gaussian mixture model (GMM) as the variational distri- bution by using which we can naturally model multimodal uncertainty in optimal actions. Considering the observations above, it is obvious that PlaNet is insufficiently uncertainty-aware, which leads to limitations on its strong potential. Although the training procedure employed in PlaNet is based on autoencoding variational inference [15], the model parameters are estimated as fixed-points θ, underestimating the model uncertainty p(θ|D). For the purpose of planning, the cross entropy method (CEM) [16] is heuristically introduced for trajectory optimization, which ignores the multimodal uncertainty in optimal actions. Motivated by this, in the present study, we reconsider PlaNet from a Bayesian viewpoint, aiming to propose an extension of PlaNet, referred to as PlaNet of the Bayesians (PlaNet-Bayes). The primary contributions, which characterize PlaNet-Bayes, can be summarized as follows; • We propose incorporating uncertainty in latent statespace models by considering approximate inference of the posterior p(θ|D) with a neural network ensemble. • We formulate VI-MPC for partially observable environments by considering latent planning as variational inference. Exploiting the newly derived framework, we also introduce a latent version of PaETS to involve multimodality in optimal actions.
The differences between the proposed method and the baseline PlaNet are summarized in the bottom part of Fig. 1. By involving the two types of the uncertainty, PlaNet-Bayes can ahieve the performance consistently better compared with PlaNet. The remainder of this paper is organized as follows. In Sec. II, we provide a brief review on PlaNet, VI-MPC, and PaETS. In Sec. III, we describe the proposed PlaNet-Bayes in detail. In Sec. IV, the effectiveness of PlaNet-Bayes is demonstrated through evaluations using the DeepMind control suite [17].

II. PRELIMINARY
A. PlaNet: Deep Planning Network 1) Autoencoding Variational Bayes for Time Series: Let us begin with considering the graphical model illustrated in Fig. 2(a). In this section, we focus on z ≤t and their adjacent nodes. The remaining nodes, namely z >t , a ≥t , and O >t , are discussed later in Sec. III-B.1. The joint distribution of the focused variables is defined as follows: p (x t |z t ) .
:=p(x ≤t |z ≤t ) (1) As in the case of well-known variational autoencoders (VAEs) [15], generative models p(z t+1 |z t , a t ), p(x t |z t ) and inference model q(z t |x ≤t , a <t ) can be trained by maximizing the evidence lower bound (ELBO): where, If the models are parameterized with θ, this objective can be maximized by the stochastic gradient ascent via backpropagation. For the purpose of latent planning, a reward function p(r t |z t ) is also required to be formulated. To do this, we can simply regard the rewards as observations and learn the reward function along with p(x z |z t ).
2) Recurrent State-Space Model: PlaNet introduces Recurrent State-Space Model (RSSM), which assumes the latent z t which comprises z t = (s t h t ) where s t , h t are the probabilistic and deterministic variable, respectively. The generative and inference models can be formulated as: Generative models : where deterministic h t is considered as the internal state of the gated recurrent unit (GRU) f GRU (·) [18], so that historical information is embedded into h t . The architectures of the generative and inference models are illustrated in Fig. 3.
3) Latent Planning using RSSM: Algorithm 1 outlines PlaNet's latent planning strategy with CEM [16]. CEM is a stochastic method based on importance sampling that is used to iteratively update a proposal distribution to optimize an objective function by executing the following steps: (1) sample K candidates from the proposal distribution, (2) then evaluate the objective function for each sample, and (3) update the proposal distribution using the results of evaluation. Algorithm 1 summarizes the process executed by PlaNet to implements the above steps for latent planning.
(1) At 5, K candidate action sequences are sampled from the diagonal Gaussian proposal parameterized with mean µ t:t+T −1 and variance σ t:t+T −1 . In the pseudo-code, the subscript t:t+T −1 is omitted for readability. (2) Starting from the current state (h t , s t ) estimated at 1-3, latent trajectories and step rewards are sampled up to T time-steps at 6-10. (3) Using the trajectory rewards calculated at 11, the parameters µ, σ are adjusted according to the CEM update law at 12-14, where 1[·] is an indicator function and R thd is determined so that top-e% of samples satisfy the threshold condition (e = 10% is used in [4]). This iterative update is executed U times.
Algorithm 1: PlaNet's latent planning based on CEM [4] Input: Current observation xt, Previous latent states and action (h t−1 , s t−1 , a t−1 ), Initial parameters of the proposal distribution (µ (0) , σ (0) ) Output: Optimized parameters of proposal dist. (µ (U ) , σ (U ) ) Current latent states (ht, st) // (0) Estimate current latent state Eval. the objective for each candidate 6 Sample trajectories and rewards B. VI-MPC and PaETS in Fully Observable Environments Figure 2(b) represents the graphical model that is used to derive original VI-MPC [12] based on the control as inference framework [14]. To formulate optimal control as inference, a binary random variable O t ∈ {0, 1} is auxiliarily introduced to represent the optimality of state z t . Note that z t is not latent state here. Let us consider the trajectory posterior conditioned on the optimality p(a ≥t , z >t |O >t ). Hereinafter, we denote a ≥t , z >t and O >t as; a, z and O for readability. By solving a variational inference problem: argmin q KL(q(a, z)||p(a, z|O)), we obtain the iterative law to update the variational distribution q as per equation bellow: where j indicates the loop count, λ is the inverted step-size to control optimization speed, and κ is the weight of the entropy regularization term q −κ . W is defined as: This is a general framework called VI-MPC that generalizes several MPC methods. Different definitions of optimality likelihood p(O|z) recover various methods including CEM, path integral control [19], [20], covariance matrix adaptation evolution strategy (CMA-ES) [21], and proportional CEM [22]. The above-mentioned methods generally assume that q is Guassian. However, VI-MPC can define q arbitrarily, and PaETS defines q as GMM successfully incorporating multimodality of optimal actions. The original formulation of VI-MPC supposes fully observable environments, and application to partially observable cases has not been discussed.
III. PLANET-BAYES: PLANET OF THE BAYESIANS This section describes an extension of PlaNet referred to as PlaNet of the Bayesians (PlaNet-Bayes) that implies incorporating two types of uncertainty in latent models and actions by exploiting Bayesian inference. The process of incorporating both types of uncertainty is introduced in Sections III-A and III-B.

A. Incorporating Model Uncertainty
In general, VAEs denote generative and inference models like p θ (·), q θ (·), assuming a point estimation of the model parameters θ. Here, we remove this assumption and treat θ as a random variable. As indicated in Eq. 2, maximizing ELBO also leads to maximization of p(D|θ), and therefore we can regard VAEs' general training procedure as a maximum likelihood estimation. Instead, by inferring the posterior p(θ|D), we incorporate the uncertainty in the model parameters of RSSM. Given a sufficiently parameterized model, i.e., a deep neural network, promising schemes for approximating the posterior are stochastic gradient MCMC [23], dropout as variational inference [6]- [8], and neural network ensembles [9]- [12].
In this paper, we use the ensemble scheme owing to its simplicity and better performance compared with dropout [12]. This scheme is employed to approximate the posterior as a set of particles p(θ|D) where E is the ensemble size (namely, the number of networks) and δ is Dirac delta function. This approximation can successfully incorporate multimodal uncertainty in the exact posterior. Each particle θ i is independently trained by stochastic gradient descent so as to (sub-)optimize p(θ|D) ∝ p(D|θ)p(θ). In the proposed modeling scheme, GRU, FC1, and FC2, as presented in Fig. 3, are implemented as ensemble networks, and the ensemble size is set to be E = 5 as same as defined in [9], [12].
B. Incorporating Action Uncertainty 1) Derivation of latent VI-MPC: We derive VI-MPC for partially observable environments by formulating latent planning as a variational inference problem. We refer to the graphical model of Fig. 2(a) again for this formulation. For the purpose of clarity, in this figure, we omit the random variable θ using which the latent state transition is conditioned, namely, p(z t |z t−1 , a t−1 , θ). The joint distribution of all variables in this figure is: where, and a non-informative action prior p(a) is supposed. The subscripts of z 1:t+T , a 1:t+T −1 are omitted. The objective of this formulation is to infer the posterior: p(a ≥t , z, θ|O ≥t , x ≤t ) = p joint (·) p joint (·)da ≥t dzdθ .
As the inference of this posterior is intractable, instead, we estimate the variational distribution q(a ≥t , z, θ) that minimizes KL(q(a ≥t , z, θ)||p(a ≥t , z, θ|O >t , x ≤t )). We suppose that q is factorized as: This variational inference problem can be solved by maximizing the ELBO: By applying the mirror descent [12], [24], [25] to this optimization problem, we can derive an update law for q(a ≥t ), which takes the same form as Eq. 5. At the same time, W(a ≥t ) is defined differently from the original formulation: W(a ≥t ) := E p(z|a,θ),p(θ|D) [p(x ≤t |z ≤t )p(O >t |z >t )]. (12) A major difference from the original VI-MPC is that the observation likelihood p(x ≤t |z ≤t ) should be considered in Eq. 12. One may consider that Eq. 12 can be efficiently implemented with Sequential Monte Carlo (SMC also referred to as particle filter) [26] using the generative models; namely, for t ≤ t, predict particles by p(z t |z t −1 , a t −1 , θ) and conduct resampling with the likelihood p(x t |z t ). Because of the fact that this yields rather a complicated process, let us consider to approximate it by utilizing the inference model. By applying importance sampling with q(z ≤t |x ≤t , a ≤t , θ), Eq. 12 can be rearranged as: where, P := q(z ≤t |x ≤t , a ≤t , θ)p(z >t |a ≥t , θ)p(θ|D).
Having this distribution P, z ≤t and z >t are sampled from the inference model q(z t |·) and generative model p(z t |·), respectively. As these models are trained so as to minimize the complexity loss in Eq. 2, we can expect that the likelihood ratio in Eq. 13, i.e., p(z ≤t |·)/q(z ≤t |·), can be canceled.
In addition, minimization of the reconstruction loss in Eq. 2 allow realizing successful autoencoding x → z → x so that Therefore, the likelihood p(x ≤t |z ≤t ) can be approximately pulled out from E P [·] and considered as canceled in Eq. 5. On the basis of these observations, we rewrite Eq. 13 as: Eqs. 5, 14, and 16 suggest general VI-MPC for the latent state-space models. The planning method used in PlaNet is a special case of VI-MPC, assuming that (1) the variational distribution q is Gaussian; (2) the optimality likelihood is In this study, same optimality likelihood with PlaNet is introduced.
2) PaETS for latent planning: We introduce a latent version of PaETS using the proposed latent VI-MPC. PaETS uses GMM as the variational distribution q as: and M is the number of components in the mixture model. By following the derivation procedure similarly as in [12], we obtain the update laws of φ (j+1) , which take the weight-average form like 14 of Algorithm 1: The complete definition of Eq. 18 is available in Appendix I.

C. Procedure and Implementation
Algorithms 2 and 3 summarize the steps of the proposed method. The outermost loop of Algorithm 2 describes the training of the posterior p(θ|D) (namely, neural network ensemble), at which the model is iteratively trained at 3. The trained model is tested on the MPC loop at 6-11, whereas D is augmented according to the executed trajectories. This paper realizes GMM parameter initialization at 7 as follows; µ The procedure in Algorithm 3 is rather similar to that one of in Algorithm 1. One of the primary differences is that the expectation E P [·] in Eq. 16 is approximated with E samples obtained from the E ensemble networks, whereas PlaNet uses only a single sample. Another difference is that PaETS is employed to update the variational distribution parameter φ at 12 1 . We implement PlaNet-Bayes in TensorFlow [27] by modifing the official source code of PlaNet 2 . We keep the most of hyperparameters and experimental conditions similar as the original ones except for the number of action candidates K (originally K = 1, 000). As E P [·] is approximated with E = 5 samples, we have to sample K × E trajectories at 6-10 in Algorithm 3, which requires E-times larger computations. To relieve this, we set K ← K/E(= 1, 000/5 = 200) so that the same number of trajectories are evaluated; namely the total number of multiply-accumulate operations are kept same. The other hyperparameters introduced in this papers are κ = 0, λ = 1, and M = 5.

A. Comparison with PlaNet
The main objective of this experiment is to demonstrate that PlaNet-Bayes has advantages over the baseline method 1 It should be noted that the heuristics discussed in [12] is introduced at 11-12. Let us describe the optimality likelihood as p(O ≥t |z ≥t ) := f opt (R(z)), where f opt (·) is a monotonic increasing function and R(z) is a trajectory reward function. The heuristics use W (a ≥t ) := f opt (E[R(z)]) instead of W(a ≥t ) := E[f opt (R(z))]. It has been experimentally observed that these heuristics demonstrates higher optimization performance [9], [12]. 2 https://github.com/google-research/planet // (0) Estimate the current latent state // (2) Eval. the objective for each candidate 6 Sample trajectories and rewards {{{ Calc. trajectory rewards Update φ (j) by Eq. 18. Four experimental control tasks from the DeepMind Control Suite [17]. In all tasks, only third-person views (i.e., 64 × 64 × 3 pixels) are input into the MPC-policy as observations x.
PlaNet [4]. To conduct this experiment, we consider the control tasks of the DeepMind control suite [17], as shown in Fig. 4. The four difficult domains also considered in PlaNet's paper [4] are selected. Concerning the task of the "Walker" domain, a more difficult task "Run" is introduced instead of the "Walk" task originally used in [4]. In addition, for several domains, their configurations are modified so as to make training more difficult 3 . Figure 5 represents the experimental results. It can be seen that PlaNet-Bayes consistently achieves better asymptotic performance and/or faster training compared with those of PlaNet.

B. Ablation Study
This experiment is conducted to analyze how the major components of PlaNet-Bayes (model and action uncertainty) contribute to the overall improvement. Here, variants of the proposed have been prepared: either types of uncertainty are invalidated by setting either E or M equal to 1. Table I summarizes the results of the performed ablation study. Considering only model uncertainty leads to an improvement in the performance compared with PlaNet, while focusing on action uncertainty does not have any positive influence on the performance. This is because action uncertainty is rather unimodal considered alone without multimodal model uncertainty modeled by a neural network ensemble. However, when they are introduced together, multimodality in optimal actions is emphasized, and therefore, the potential of PaETS is fully exploited, achieving the best scores.

V. RELATED WORK
Recently, MBRL applications to partially observable environments have been attracting great attention; namely this question was addressed in the studies [28]- [33]. In [28], the authors utilized a general VAE objective to train the latent space models and then optimized linear policies by using CMA-ES [21]. The time-series objective similar to Eq. 2 was introduced in [29], [31], and the learned models were applied to policy optimization by using Soft Actor-Critic [34]. In [33] applies PlaNet perform to imitation learning by employing adversarial training. Although most of these studies were based on autoencoding variational Bayes, posterior inference of models was not considered. In [35], there was an attempt to extend PlaNet to be Bayesian by employing variational inference of the posterior p(θ|D). However, as experimentally suggested in [12], a tractable variational distribution q(θ), i.e., Gaussian, is less expressive than the neural network ensemble to capture multimodality. In addition, the experiment presented in [35], which was conducted using the "Cheetah" domain, did not the achieve asymptotic performance improvement. Regarding uncertainty-aware planning, the research works mentioned above did not consider the action uncertainty. To the best of our knowledge, PlaNet-Bayes is the first attempt to incorporate uncertainty and demonstrate its efficiency by achieving better performance compared with the state-of-the-art latent MPC method: PlaNet.

VI. CONCLUSION
In the present paper, we proposed PlaNet-Bayes, a Bayesian extension of the state-of-the-art MBRL method for partially observable environments PlaNet. Bayesian inference of the model posterior p(θ|D) was introduced such as to be realized by the ensemble of latent dynamics models. The other Bayesian concept was employed for inference of the optimal trajectory posterior, which allowed formulating VI-MPC and PaETS for latent planning to successfully incorporate the multimodal uncertainty in optimal actions. By exploiting both considered uncertainty-aware strategies, PlaNet-Bayes was able to improve asymptotic performance compared to with that of baseline PlaNet.
The approaches proposed in this paper are also applicable to a variety of control methods for partially observable environments. For example, the ensemble scheme of the latent state-space model could be used to improve policy-oriented MBRL performance [28], [29], [31]. On the other hand, by introducing a categorical distribution (or a mixture model of it) as a variational distribution q, latent planning for discrete control tasks, including video-and board-games [32], [36], [37], is possible. Future research directions will be related to experiments on latent MPC in real systems. Specifically in the case of industrial systems, deep understanding of the learned models and latent space is essential to obtain information about the agent's decision-making process. To represent the explainable latent space, we will consider adopting disentangling approaches [38], [39] as a promising research direction. The proposed model ensemble approach may also contribute to analysis and enhancement of the decision-making, as the confidence of trajectory prediction can be quantified by using multiple prediction outputs similarly as in [40], which suggests what the new data can be collected to improve the confidence by reducing the uncertainty.