neural-mpc
None
view repo
Model-free deep reinforcement learning algorithms have been shown to be capable of learning a wide range of robotic skills, but typically require a very large number of samples to achieve good performance. Model-based algorithms, in principle, can provide for much more efficient learning, but have proven difficult to extend to expressive, high-capacity models such as deep neural networks. In this work, we demonstrate that medium-sized neural network models can in fact be combined with model predictive control (MPC) to achieve excellent sample complexity in a model-based reinforcement learning algorithm, producing stable and plausible gaits to accomplish various complex locomotion tasks. We also propose using deep neural network dynamics models to initialize a model-free learner, in order to combine the sample efficiency of model-based approaches with the high task-specific performance of model-free methods. We empirically demonstrate on MuJoCo locomotion tasks that our pure model-based approach trained on just random action data can follow arbitrary trajectories with excellent sample efficiency, and that our hybrid algorithm can accelerate model-free learning on high-speed benchmark tasks, achieving sample efficiency gains of 3-5x on swimmer, cheetah, hopper, and ant agents. Videos can be found at https://sites.google.com/view/mbmf
READ FULL TEXT VIEW PDF
Integrating model-free and model-based approaches in reinforcement learn...
read it
Recent success in deep reinforcement learning for continuous control has...
read it
The future of mobility-as-a-Service (Maas)should embrace an integrated s...
read it
Visual servoing involves choosing actions that move a robot in response ...
read it
In the current level of evolution of Soccer 3D, motion control is a key
...
read it
Model usage is the central challenge of model-based reinforcement learni...
read it
We propose a simple data augmentation technique that can be applied to
s...
read it
None
Model-free deep reinforcement learning algorithms have been shown to be capable of learning a wide range of tasks, ranging from playing video games from images [1, 2] to learning complex locomotion skills [3]. However, such methods suffer from very high sample complexity, often requiring millions of samples to achieve good performance [3]. Model-based reinforcement learning algorithms are generally regarded as being more efficient [4]. However, to achieve good sample efficiency, these model-based algorithms have conventionally used either simple function approximators [5] or Bayesian models that resist overfitting [6] in order to effectively learn the dynamics using few samples. This makes them difficult to apply to a wide range of complex, high-dimensional tasks. Although a number of prior works have attempted to mitigate these shortcomings by using large, expressive neural networks to model the complex dynamical systems typically used in deep reinforcement learning benchmarks [7, 8], such models often do not perform well [9] and have been limited to relatively simple, low-dimensional tasks [10].
In this work, we demonstrate that multi-layer neural network models can in fact achieve excellent sample complexity in a model-based reinforcement learning algorithm, when combined with a few important design decisions such as data aggregation. The resulting models can then be used for model-based control, which we perform using model predictive control (MPC) with a simple random-sampling shooting method [11]. We demonstrate that this method can acquire effective locomotion gaits for a variety of MuJoCo benchmark systems, including the swimmer, half-cheetah, hopper, and ant. In fact, effective gaits can be obtained from models trained entirely off-policy, with data generated by taking only random actions. Fig. 1 shows these models can be used at run-time to execute a variety of locomotion tasks such as trajectory following, where the agent can execute a path through a given set of sparse waypoints that represent desired center-of-mass positions. Additionally, less than four hours of random action data was needed for each system, indicating that the sample complexity of our model-based approach is low enough to be applied in the real world.
Although such model-based methods are drastically more sample efficient and more flexible than task-specific policies learned with model-free reinforcement learning, their asymptotic performance is usually worse than model-free learners due to model bias. Model-free algorithms are not limited by the accuracy of the model, and therefore can achieve better final performance, though at the expense of much higher sample complexity [4, 12]. To address this issue, we use our model-based algorithm to initialize a model-free learner. The learned model-based controller provides good rollouts, which enable supervised initialization of a policy that can then be fine-tuned with model-free algorithms, such as policy gradients. We empirically demonstrate that the resulting hybrid model-based and model-free (Mb-Mf) algorithm can accelerate model-free learning, achieving sample efficiency gains of on the swimmer, cheetah, hopper, and ant MuJoCo locomotion benchmarks [8] as compared to pure model-free learning.
The primary contributions of our work are the following: (1) we demonstrate effective model-based reinforcement learning with neural network models for several contact-rich simulated locomotion tasks from standard deep reinforcement learning benchmarks, (2) we empirically evaluate a number of design decisions for neural network dynamics model learning, and (3) we show how a model-based learner can be used to initialize a model-free learner to achieve high rewards while drastically reducing sample complexity.
Deep reinforcement learning algorithms based on Q-learning [13, 2, 9], actor-critic methods [14, 15, 16], and policy gradients [3, 17] have been shown to learn very complex skills in high-dimensional state spaces, including simulated robotic locomotion, driving, video game playing, and navigation. However, the high sample complexity of purely model-free algorithms has made them difficult to use for learning in the real world, where sample collection is limited by the constraints of real-time operation. Model-based algorithms are known in general to outperform model-free learners in terms of sample complexity [4], and in practice have been applied successfully to control robotic systems both in simulation and in the real world, such as pendulums [6], legged robots [18], swimmers [19], and manipulators [20]. However, the most efficient model-based algorithms have used relatively simple function approximators, such as Gaussian processes [6, 21, 22], time-varying linear models [5, 23, 24], and mixtures of Gaussians [25]. PILCO [6], in particular, is a model-based policy search method which reports excellent sample efficiency by learning probabilistic dynamics models and incorporating model uncertainty into long-term planning. These methods have difficulties, however, in high-dimensional spaces and with nonlinear dynamics. The most high-dimensional task demonstrated with PILCO that we could find has 11 dimensions [19], while the most complex task in our work has 49 dimensions and features challenging properties such as frictional contacts. To the best of our knowledge, no prior model-based method utilizing Gaussian processes has demonstrated successful learning for locomotion with frictional contacts, though several works have proposed to learn the dynamics, without demonstrating results on control [26].
Although neural networks were widely used in earlier work to model plant dynamics [27, 28], more recent model-based algorithms have achieved only limited success in applying such models to the more complex benchmark tasks that are commonly used in deep reinforcement learning. Several works have proposed to use deep neural network models for building predictive models of images [29], but these methods have either required extremely large datasets for training [29] or were applied to short-horizon control tasks [30]. In contrast, we consider long-horizon simulated locomotion tasks, where the high-dimensional systems and contact-rich environment dynamics provide a considerable modeling challenge. [10] proposed a relatively complex time-convolutional model for dynamics prediction, but only demonstrated results on low-dimensional (2D) manipulation tasks. [31] extended PILCO [6] using Bayesian neural networks, but only presented results on a low-dimensional cart-pole swingup task, which does not include frictional contacts.
Aside from training neural network dynamics models for model-based reinforcement learning, we also explore how such models can be used to accelerate a model-free learner. Prior work on model-based acceleration has explored a variety of avenues. The classic Dyna [32] algorithm proposed to use a model to generate simulated experience that could be included in a model-free algorithm. This method was extended to work with deep neural network policies, but performed best with models that were not neural networks [9]. Other extensions to Dyna have also been proposed [33, 34]. Model learning has also been used to accelerate model-free Bellman backups [35], but the gains in performance from including the model were relatively modest, compared to the and
speed-ups that we report from our hybrid Mb-Mf experiments. Prior work has also used model-based learners to guide policy optimization through supervised learning
[36], but the models that were used were typically local linear models. In a similar way, we also use supervised learning to initialize the policy, but we then fine-tune this policy with model-free learning to achieve the highest returns. Our model-based method is more flexible than local linear models, and it does not require multiple samples from the same initial state for local linearization.The goal of reinforcement learning is to learn a policy that maximizes the sum of future rewards. At each time step , the agent is in state , executes some action , receives reward , and transitions to the next state according to some unknown dynamics function . The goal at each time step is to take the action that maximizes the discounted sum of future rewards, given by , where is a discount factor that prioritizes near-term rewards. Note that performing this policy extraction requires either knowing the underlying reward function
or estimating the reward function from samples
[37]. In this work, we assume access to the underlying reward function, which we use for planning actions under the learned model.In model-based reinforcement learning, a model of the dynamics is used to make predictions, which is used for action selection. Let denote a learned discrete-time dynamics function, parameterized by , that takes the current state and action and outputs an estimate of the next state at time . We can then choose actions by solving the following optimization problem:
(1) |
In practice, it is often desirable to solve this optimization at each time step, execute only the first action from the sequence, and then replan at the next time step with updated state information. Such a control scheme is often referred to as model predictive control (MPC), and is known to compensate well for errors in the model.
We now present our model-based deep reinforcement learning algorithm. We detail our learned dynamics function in Sec. IV-A, how to train the learned dynamics function in Sec. IV-B, how to extract a policy with our learned dynamics function in Sec. IV-C, and how to use reinforcement learning to further improve our learned dynamics function in Sec. IV-D.
We parameterize our learned dynamics function
as a deep neural network, where the parameter vector
represents the weights of the network. A straightforward parameterization for would take as input the current state and action , and output the predicted next state . However, this function can be difficult to learn when the states and are too similar and the action has seemingly little effect on the output; this difficulty becomes more pronounced as the time between states becomes smaller and the state differences do not indicate the underlying dynamics well.We overcome this issue by instead learning a dynamics function that predicts the change in state over the time step duration of . Thus, the predicted next state is as follows: . Note that increasing this increases the information available from each data point, and can help with not only dynamics learning but also with planning using the learned dynamics model (Sec. IV-C). However, increasing also increases the discretization and complexity of the underlying continuous-time dynamics, which can make the learning process more difficult.
Collecting training data: We collect training data by sampling starting configurations , executing random actions at each timestep, and recording the resulting trajectories of length . We note that these trajectories are very different from the trajectories the agents will end up executing when planning with this learned dynamics model and a given reward function (Sec. IV-C), showing the ability of model-based methods to learn from off-policy data.
Data preprocessing: We slice the trajectories into training data inputs and corresponding output labels
. We then subtract the mean of the data and divide by the standard deviation of the data to ensure the loss function weights the different parts of the state (e.g., positions and velocities) equally. We also add zero mean Gaussian noise to the training data (inputs and outputs) to increase model robustness. The training data is then stored in the dataset
.Training the model: We train the dynamics model by minimizing the error
(2) |
using stochastic gradient descent. While training on the training dataset
, we also calculate the mean squared error in Eqn. 2 on a validation set , composed of trajectories not stored in the training dataset.Although this error provides an estimate of how well our learned dynamics function is at predicting next state, we would in fact like to know how well our model can predict further into the future because we will ultimately use this model for longer-horizon control (Sec. IV-C). We therefore calculate -step validation errors by propagating the learned dynamics function forward times to make multi-step open-loop predictions. For each given sequence of true actions from , we compare the corresponding ground-truth states to the dynamics model’s multi-step state predictions , calculated as
(3) |
This -step validation is used to analyze our experimental results, but otherwise not used during training.
In order to use the learned model , together with a reward function that encodes some task, we formulate a model-based controller that is both computationally tractable and robust to inaccuracies in the learned dynamics model. Expanding on the discussion in Sec. III, we first optimize the sequence of actions over a finite horizon , using the learned dynamics model to predict future states:
(4) |
Calculating the exact optimum of Eqn. 4 is difficult due to the dynamics and reward functions being nonlinear, but many techniques exist for obtaining approximate solutions to finite-horizon control problems that are sufficient for succeeding at the desired task. In this work, we use a simple random-sampling shooting method [38] in which candidate action sequences are randomly generated, the corresponding state sequences are predicted using the learned dynamics model, the rewards for all sequences are calculated, and the candidate action sequence with the highest expected cumulative reward is chosen. Rather than have the policy execute this action sequence in open-loop, we use model predictive control (MPC): the policy executes only the first action , receives updated state information , and recalculates the optimal action sequence at the next time step. Note that for higher-dimensional action spaces and longer horizons, random sampling with MPC may be insufficient, and investigating other methods [39] in future work could improve performance.
Note that this combination of predictive dynamics model plus controller is beneficial in that the model is trained only once, but by simply changing the reward function, we can accomplish a variety of goals at run-time, without a need for live task-specific retraining.
To improve the performance of our model-based learning algorithm, we gather additional on-policy data by alternating between gathering data with our current model and retraining our model using the aggregated data. This on-policy data aggregation (i.e., reinforcement learning) improves performance by mitigating the mismatch between the data’s state-action distribution and the model-based controller’s distribution [40]. Alg. 1 and Fig. 2 provide an overview of our model-based reinforcement learning algorithm.
First, random trajectories are collected and added to dataset , which is used to train by performing gradient descent on Eqn. 2. Then, the model-based MPC controller (Sec. IV-C) gathers new on-policy datapoints and adds these datapoints to a separate dataset . The dynamics function is then retrained using data from both and . Note that during retraining, the neural network dynamics function’s weights are warm-started with the weights from the previous iteration. The algorithm continues alternating between training the model and gathering additional data until a predefined maximum iteration is reached. We evaluate design decisions related to data aggregation in our experiments (Sec. VI-A).
The model-based reinforcement learning algorithm described above can learn complex gaits using very small numbers of samples, when compared to purely model-free learners. However, on benchmark tasks, its final performance still lags behind purely model-free algorithms. To achieve the best final results, we can combine the benefits of model-based and model-free learning by using the model-based learner to initialize a model-free learner. We propose a simple but highly effective method for combining our model-based approach with off-the-shelf, model-free methods by training a policy to mimic our learned model-based controller, and then using the resulting imitation policy as the initialization for a model-free reinforcement learning algorithm.
We first gather example trajectories with the MPC controller detailed in Sec. IV-C, which uses the learned dynamics function that was trained using our model-based reinforcement learning algorithm (Alg. 1). We collect the trajectories into a dataset , and we then train a neural network policy to match these “expert” trajectories in . We parameterize as a conditionally Gaussian policy , in which the mean is parameterized by a neural network , and the covariance is a fixed matrix. This policy’s parameters are trained using the behavioral cloning objective
(5) |
which we optimize using stochastic gradient descent. To achieve desired performance and address the data distribution problem, we applied DAGGER [40]: This consisted of iterations of training the policy, performing on-policy rollouts, querying the “expert” MPC controller for “true” action labels for those visited states, and then retraining the policy.
After initialization, we can use the policy , which was trained on data generated by our learned model-based controller, as an initial policy for a model-free reinforcement learning algorithm. Specifically, we use trust region policy optimization (TRPO) [3]; such policy gradient algorithms are a good choice for model-free fine-tuning since they do not require any critic or value function for initialization [41], though our method could also be combined with other model-free RL algorithms.
TRPO is also a common choice for the benchmark tasks we consider, and it provides us with a natural way to compare purely model-free learning with our model-based pre-initialization approach. Initializing TRPO with our learned expert policy is as simple as using as the initial policy for TRPO, instead of a standard randomly initialized policy. Although this approach of combining model-based and model-free methods is extremely simple, we demonstrate the efficacy of this approach in our experiments.
We evaluated our model-based reinforcement learning approach (Alg. 1) on agents in the MuJoCo [8] physics engine. The agents we used were swimmer (), hopper (), half-cheetah (), and ant (). Relevant parameter values and implementation details are listed in the Appendix, and videos of all our experiments are provided online^{1}^{1}1https://sites.google.com/view/mbmf.
We first evaluate various design decisions for model-based reinforcement learning with neural networks using empirical evaluations with our model-based approach (Sec. IV). We explored these design decisions on the swimmer and half-cheetah agents on the locomotion task of running forward as quickly as possible. After each design decision was evaluated, we used the best outcome of that evaluation for the remainder of the evaluations.
(A) Training steps. Fig. 6
a shows varying numbers of gradient descent steps taken during the training of the learned dynamics function. As expected, training for too few epochs negatively affects learning performance, with 20 epochs causing swimmer to reach only half of the other experiments’ performance.
(B) Dataset aggregation. Fig. 6b shows varying amounts of (initial) random data versus (aggregated) on-policy data used within each mini-batch of stochastic gradient descent when training the learned dynamics function. We see that training using mostly the aggregated on-policy rollouts significantly improves performance, revealing the benefits of improving learned models with reinforcement learning.
(C) Controller. Fig. 6c shows the effect of varying the horizon and the number of random samples used at each time step by the model-based controller. We see that too short of a horizon is harmful for performance, perhaps due to greedy behavior and entry into unrecoverable states. Additionally, the model-based controller for half-cheetah shows worse performance for longer horizons. This is further revealed below in Fig. 5, which illustrates a single 100-step validation rollout (as explained in Eqn. 3). We see here that the open-loop predictions for certain state elements, such as the center of mass x position, diverge from ground truth. Thus, a large leads to the use of an inaccurate model for making predictions, which is detrimental to task performance. Finally, with regards to the number of randomly sampled trajectories evaluated, we expect this value needing to be higher for systems with higher-dimensional action spaces.
(D) Number of initial random trajectories. Fig. 6d shows varying numbers of random trajectories used to initialize our model-based approach. We see that although a higher amount of initial training data leads to higher initial performance, data aggregation allows low-data initialization runs to reach a high final performance level, highlighting how on-policy data from reinforcement learning improves sample efficiency.
For the task of trajectory following, we evaluated our model-based reinforcement learning approach on the swimmer, ant, and half-cheetah environments (Fig. 3). Note that for these tasks, the dynamics model was trained using only random initial trajectories and was trained only once per agent, but the learned model was then used at run-time to accomplish different tasks. These results show that the models learned using our method are general enough to accommodate new tasks at test time, including tasks that are substantially more complex than anything that the robot did during training, such as following a curved path or making a U-turn. Furthermore, we show that even with the use of such a naïve random-sampling controller, the learned dynamics model is powerful enough to perform a variety of tasks.
The reward function we use requires the robot to track the desired x/y center of mass positions. This reward consists of one term to penalize the perpendicular distance away from the desired trajectory, and a second term to encourage forward movement in the direction of the desired trajectory. The reward function does not tell the robot anything about how the limbs should be moved to accomplish the desired center of mass trajectory. The model-based algorithm must discover a suitable gait entirely on its own. Further details about this reward are included in the appendix.
We now compare our pure model-based approach with a pure model-free method on standard benchmark locomotion tasks, which require a simulated robot (swimmer, half-cheetah, hopper, or ant) to learn the fastest forward-moving gait possible. The model-free approach we compare with is the rllab [42] implementation of trust region policy optimization (TRPO) [3], which has obtained state-of-the-art results on these tasks.
For our model-based approach, we used the OpenAI gym [7] standard reward functions (listed in the appendix) for action selection in order to allow us to compare performance to model-free benchmarks. These reward functions primarily incentivize speed, and such high-level reward functions make it hard for our model-based method to succeed due to the myopic nature of the short-horizon MPC that we employ for action selection; therefore, the results of our model-based algorithm on all following plots are lower than would be if we designed our own reward function (for instance, a straight-line trajectory following reward function).
Even with the extremely simplistic given reward functions, the agents can very quickly learn a gait that makes forward progress. The swimmer, for example, can quickly achieve qualitatively good moving forward behavior at faster than the model-free method. However, the final achieved rewards of our pure model-based approach were not sufficient to match the final performance of state-of-the-art model-free learners. Therefore, we combine our sample-efficient model-based method with a high-performing model-free method. In Fig. 8, we show results comparing our pure model-based approach, a pure model-free approach (TRPO), and our hybrid Mb-Mf approach.
With our pure model-based approach, these agents all learn a reasonable gait in very few steps. In the case of the hopper, our pure model-based approach learns to perform a double or triple hop very quickly in 1e4 steps, but performance plateaus as the reward signal of just forward velocity is not enough for the limited-horizon controller to keep the hopper upright for longer periods of time. Our hybrid Mb-Mf approach takes these quickly-learned gaits and performs model-free fine-tuning in order to achieve task success, achieving sample efficiency gains over pure model-free methods for all agents.
We presented a model-based reinforcement learning algorithm that is able to learn neural network dynamics functions for complex simulated locomotion tasks using a small numbers of samples. Although a number of prior works have explored model-based learning with neural network dynamics models, our method achieves excellent performance on a number of challenging locomotion problems that exceed the complexity demonstrated in prior methods.
We described a number of important design decisions for effectively and efficiently training neural network dynamics models, and we presented detailed experiments that evaluated these design parameters. Our method quickly discovered a dynamics model that led to an effective gait, and that model could be applied to different trajectory following tasks at run-time, or the initial gait could then be fine-tuned with model-free learning to achieve high task rewards on benchmark Mujoco agents.
In addition to looking at the difference in sample complexity between our hybrid Mb-Mf approach and a pure model-free approach, there are also takeaways from the model-based approach alone. Our model-based algorithm cannot always reach extremely high rewards on its own, but it offers practical use by allowing the successful extraction of complex and realistic gaits. In general, our model-based approach can very quickly become competent at a task, whereas model-free approaches require immense amounts of data, but can become experts. For most practical applications, this competence that we achieve with our model-based approach is exactly what we need: For example, when we have a small legged robot with unknown dynamics and we want it to accomplish tasks in the real-world (such as exploration, construction, search and rescue, etc.), achieving reliable walking gaits that can follow any desired trajectory is a superior skill to that of just running straight forward as fast as possible. Additionally, consider the ant: A model-free approach requires 5e6 points to achieve a steady walking forward gait, but using just of those data points, our model-based approach can allow for travel in any direction and along arbitrary desired trajectories. Training such a dynamics model only once and applying it to various tasks is compelling; especially when looking toward application to real robots, this sample efficiency brings these methods out of the simulation world and into the realm of feasibility.
While the simplicity and effectiveness of our Mb-Mf approach is enticing for ease of practical application, an interesting avenue for future work is to integrate our model-based approach more tightly and elegantly with model-free learners (Q-learning, actor-critic methods), in order to provide further sample efficiency gains.
Another exciting direction for future work is to deploy this method on real-world robotic systems, where the improved sample efficiency would make it practical to use even under the constraints of real-time sample collection in the real world. From the experiments shown in this paper, our method has shown applicability for systems with high-dimensional state spaces, systems with contact-rich environment dynamics, under-observed systems, and systems with complex nonlinear dynamics that provide a considerable modelling challenge. In addition to taking communication delays and computational limitations into account, another line of future work includes improving the MPC controller. In this paper, we chose to use a naïve random-sampling controller to further emphasize the power of the learned dynamics models; however, this may not be feasible on real systems with limited computational power, or on systems with high-dimensional actions spaces that would require a large number of actions to sampled. Thus, further development of a real-time controller via optimization techniques is compelling future work.
We thank Vitchyr Pong for running some baseline experiments. This work is supported by the National Science Foundation under the National Robotics Initiative, Award CMMI-1427096, as well as IIS-1637443, IIS-1614653, and a NSF Graduate Research Fellowship.
Workshop on Deep Learning, NIPS
, 2013.Data-Efficient Machine Learning workshop
, 2016.
Comments
There are no comments yet.