L EARNING P HYSICS P RIORS FOR D EEP R EINFORCEMENT L EARNING
Anonymous authors
Paper under double-blind review
A BSTRACT
While model-based deep reinforcement learning (RL) holds great promise for sample efﬁciency and generalization, learning an accurate dynamics model is challenging and often requires substantial interactions with the environment.
Further, a wide variety of domains have dynamics that share common foundations like the laws of physics, which are rarely exploited by these algorithms.
Humans often acquire such physics priors that allow us to easily adapt to the dynamics of any environment.
In this work, we propose an approach to learn such physics priors and incorporate them into an RL agent.
Our method involves pre-training a frame predictor on raw videos and then using it to initialize the dynamics prediction model on a target task.
Our prediction model, SpatialNet, is designed to implicitly capture localized physical phenomena and interactions.
We show the value of incorporating this prior through empirical experiments on two different domains – a newly created PhysWorld and games from the Atari benchmark, outperforming competitive approaches and demonstrating effective transfer learning.
I NTRODUCTION
Recent advances in deep reinforcement learning (RL) have largely relied on model-free approaches, demonstrating strong performance on a variety of domains (Silver et al., 2016; Mnih et al., 2013;
Kempka et al., 2016; Zhang et al., 2018b).
Unfortunately, model-free techniques do not have very good sample efﬁciency (Sutton, 1990) and are difﬁcult to adapt to new tasks or domains (Nichol et al., 2018).
This is mainly because a single value function represents both the agent’s policy and its knowledge of environment dynamics.
On the other hand, decoupling the dynamics model from the policy, possible with model-based RL, allows for better generalization and transfer (Zhang et al., 2018a).
However, estimating an accurate dynamics model of the environment while simultaneously using it to learn a policy is challenging and expensive, often leading to sub-optimal policies and slower learning.
One way to facilitate this process would be to initialize dynamics models with generic priors for more efﬁcient and stable model-based reinforcement learning.
t
[Figure]
Consider the scenarios in Figure 1 for example.
Both environments contain a variety of objects with different dynamics.
For an agent to obtain a good understanding of world dynamics and understand physical laws like conservation of momentum, it has to observe a large number of transitions.
For instance, observing just a couple of transitions, the agent cannot infer that the orange circle is a freely moving object while the grey rectangle is stationary.
Further, it would require a signiﬁcant number of collisions between the circle and the rectangle (at various angles and velocities) to understand the laws governing elastic collisions between two bodies, which is crucial to learning a good model of this environment.
Moreover, this entire model learning process has to be repeated from scratch for each new environment.
Humans, on the other hand, have reliable priors that allow us to learn the dynamics of new environments very quickly (Dubey et al., 2018).
In this work, we demonstrate that learning a prior of general physics (ex. concepts of velocity, mass, acceleration) allows for better and more efﬁcient estimation of the dynamics of new environments, thereby resulting in better control policies.
In order to learn a prior for physical dynamics, we utilize unsupervised learning over raw videos containing moving objects.
In particular, we ﬁrst train a dynamics model to predict the next frame given the previous k frames, over a wide variety of scenarios with moving objects.
This training allows the parameters of the dynamics model to capture the general laws of physics which are useful in predicting entity movements.
We can then use this pre-trained dynamics model as a prior in a model-based RL algorithm for a control task.
Speciﬁcally, we initialize the dynamics model with the pre-trained parameters and ﬁnetune them using transitions from the speciﬁc task.
We utilize this dynamics model in order to predict future frames up to a ﬁnite horizon, which are then used as an additional context input into a policy network, similar to the approach of Weber et al.
We show that this results in both faster learning and more optimal policies.
We characterize our dynamics model as an image pixel prediction model.
Learning a good future frame model is challenging (Mathieu et al., 2015), mainly because of two reasons - a) the highdimensionality of the output space with arbitrary number of moving objects and interactions, and b) the partial observability in environments.
Existing techniques that use a combination of recurrent and convolutional networks (Oh et al., 2015) suffer from the problem of error compounding and poor generalization as they encode a image into a single vector.
In contrast, we propose SpatialNet, a neural network that consists of a convolutional encoder, a spatial memory block, and a convolutional decoder that captures the local nature of dynamics.
The spatial memory module operates by performing convolution operations over a temporal 3-dimensional state representation that keeps spatial information intact, similar to the model of Xingjian et al.
This allows the network to capture localized physics of objects such as directional movements and collisions in a more ﬁne-grained manner, resulting in lower prediction error, better generalization and input size invariance.
We evaluate our approach and compare it with existing techniques on two different RL scenarios.
First, we consider PhysWorld, a suite of randomized physics-focused games, where learning object movement is crucial to a successful policy.
Second, we also evaluate on a stochastic variant of the popular ALE framework consisting of Atari games Bellemare et al.
In both scenarios, we ﬁrst demonstrate the value of learning a physics prior for model dynamics — our agent achieves up to 130% higher performance on a shooting game, PhysShooter and 49.8% higher on the Atari game of
Asteroids, compared to the most competitive baseline.
Further, we also show that the dynamics model ﬁne-tuned on these tasks can transfer to new tasks effectively.
For instance, our model achieves a relative score improvement of 37.4% on transfer from PhysForage to PhysShooter, than compared to a relative score improvement of 5.4% from a policy-transfer baseline.
R ELATED W ORK
Video prediction and reinforcement learning Our frame prediction model is closest in spirit to the ConvolutionalLSTM which has been applied to several domains including weather forecasting (Xingjian et al., 2015), gesture recognition (Zhu et al., 2017), and forecasting passenger demand (Ke et al., 2017).
Similar architectures that incorporate differentiable memory modules have been proposed (Patraucean et al., 2015), with applications to deep RL (Parisotto and Salakhutdinov, 2017).
We use a simpler architecture, which we show generalizes better at capturing dynamics, that captures entity movements more directly and demonstrate its use in learning useful physics priors for environment dynamics.
Several recent methods have combined policy learning with future frame prediction in various ways.
Action-conditioned frame prediction (Oh et al., 2015; Finn et al., 2016; Weber et al., 2017) has been used to simulate trajectories for policy learning.
Predicted frames have also been used to incentivize exploration in agents, via hashing (Yin et al., 2017) or using the prediction error to provide intrinsic rewards (Pathak et al., 2017).
The main departure of our work from these papers are that we use a frame prediction model that is not conditioned on actions, which allows us to learn the model from videos independent of the task, and then use it as a prior for learning the speciﬁc dynamics of different tasks.
Physics models for reinforcement learning Incorporating physics priors into learning dynamics
models of environments has been the subject of some recent work.
Cutler et al.
; Cutler and
How (2015) learn Bayesian nonparametric priors for physical systems and use it to guide policy search.
Scholz et al.
(2014) model latent physical parameters like mass and friction and use an external physics simulator to predict future states for planning.
Kansky et al.
(2017) learn a generative physics simulator and demonstrate its usefulness in transferring policies across task variations, but require objects to be detected from raw images.
Xie et al.
(2016) develop a model that incorporates prior knowledge about the dynamics of rigidbody systems in order to perform model-predictive control.
Nguyen-Tuong and Peters (2010) use parametric physics models as priors for learning environment dynamics.
While all these approaches demonstrate the importance of having relevant priors to sample efﬁcient model learning, they all require some manual parameterization.
In contrast, we learn physics priors in the form of a predictive neural network, directly from observing raw videos.
Decoupling dynamics from policy Our work also falls into the general direction of decoupling the agent’s knowledge of the environment dynamics from its task-oriented policy.
Successor representations Dayan (1993) decompose the agent’s value function into a feature-based state representation and a reward projection operator, resulting in better exploration of the state space Kulkarni et al.
Barreto et al.
; Machado et al. (2017b).
While these state abstractions help with exploration, such representations do not explicitly capture dynamics models of the environment.
Zhang et al.
(2018a) recently proposed an approach to learn two separate models for dynamics and rewards and use it to perform online planning.
However, they learn a dynamics model using task-speciﬁc transitions, while we learn a prior from task-independent videos and demonstrate its usefulness in learning different environment dynamics.
F RAMEWORK
Our goal is to demonstrate that agents can learn useful physics priors from raw videos and employ them effectively to learn dynamics of new environments.
To this end, our approach has two phases:
Pre-training : we ﬁrst design a suitable neural network architecture (SpatialNet) to predict pixels in the next frame given the previous k frames of a video.
We train this network on a newly created video dataset that captures various physical phenomena between entities.
Reinforcement learning : We use the pre-trained dynamics predictor from the previous phase to initialize the dynamics model for a reinforcement learning agent.
This dynamics model is used by the agent to predict a few frames into the future and use them as additional context for its policy.
The dynamics model is simultaneously ﬁne-tuned using trajectories observed in the task environment.
We ﬁrst describe SpatialNet, and then demonstrate how we use it for reinforcement learning.
3. S PATIAL N ET
Predicting the physical behavior of an entity requires a model that can perform two crucial operations – 1) isolation of dynamics of an entity, and 2) accurately model localized spaces and interactions around the entity.
LSTM-based recurrent networks used in prior work (
Oh et al., 2015) are ill-suited for this task since they encode the entire scene into a single latent vector, thereby losing the localized spatio-temporal correlations that are important for making accurate physical predictions.
On the other hand, the ConvLSTM (Xingjian et al., 2015) architecture has localized spatio-temporal correlations, but is not able to accurately maintain dynamics of entities due to LSTM state updates and limited separation of stationary and non-stationary objects.
In order to satisfy both the above desiderata, SpatialNet uses a spatial memory that explicitly encodes dynamics that are updated with object movement through convolutions.
This allows us to implicitly capture and maintain localized physics, such as entity velocities and collisions between entities, in our frame prediction model and allows signiﬁcantly lower long term prediction error.
Architecture SpatialNet is conceptually simple and consists of three modules.
The ﬁrst module is a standard convolutional encoder E that converts an input image x into a 3D representational map z .
The second module is a spatial memory block, σ , that converts z and the hidden state h from the previous timestep into an output representation o and new hidden state h (cid:48) .
Finally, we have a convolutional decoder D that predicts the next frame x (cid:48) from o .
Both the encoder and decoder modules ( E and D ) use two convolutional layers each with residual connections.
We implement the spatial memory block σ as a 2D convolution operation.
The module takes in a previous hidden state h t and input z t at timestep t , both of shape k × n × n where k is the number of channels and n × n is the dimensionality of the grid.
We then perform the following operations: i t = f
( C e ⊕ [ h t ; z t ]); u t = f ( C u ⊕ [ i t ; h t ]); h t = f ( C dyn ⊕ u t ); o t = f
( C d ⊕ [ z t ; h t +1 ])
[Figure]
SpatialNet
[Figure]
z t h t z t h t
[Figure]
[Figure]
where ⊕ denotes a convolution operation, [; ] denotes concatenation, C e , C u , C dyn , C d are convolutional kernels and f is a non-linearity
(we use ELU (Clevert et al., 2015)).
The module ﬁrst encodes a combination of z t and h t into a proposal state u t , using two convolutions C e , C u .
C dyn acts like a dynamics simulator and generates a new hidden state h t +1 , which captures the localized predictions for the next state around each entity.
Finally, C d uses h t +1 and z t to produce o t , encoding information about the entire frame to be rendered by subsequent decoding.
Intuitively, this architecture biases the module towards storing relevant physics information about each entity in a block of pixels at the entity’s corresponding location.
This information is sequentially updated through the convolutions, while static information such as background texture are passed directly through the input encoding z t .
We note that our spatial memory is not action-conditional, which allows us to learn from task-independent videos, as well as generalize better to new environments.
Given training videos D = (cid:110) ( x ( i ) 1 , x ( i ) 2 , . . .
, x ( i ) T i (cid:111) N i =1 , we learn the parameters of the model using a standard MSE-based loss function, L ( θ )
= (cid:80) i (cid:80) j (cid:107) ˆ x ij − x ij (cid:107) 2 .
3. R EINFORCEMENT L EARNING WITH S PATIAL N ET
There are several ways one can incorporate a learned dynamics model into a reinforcement learning setup.
One approach is to use the model to generate synthetic trajectories and use them in addition to observed transitions while training a policy (Oh et al., 2015; Feinberg et al., 2018).
Another direction is to perform rollouts from the current step using the model and then use the predicted states as additional context input to the policy (Weber et al., 2017).
Our method is similar to the latter – we use our learned dynamics model to predict k future frames and concatenate these frames along with the current frame to form the input to our policy network.
There are two differences however – (1) we predict future state observations without conditioning on the actions of the agent and without rewards since our dynamics model is task agnostic, and (2) we do not use a global encoding for future frames, but stack frames and use convolutions to extract local dynamic information.
Formally, we consider a standard Markov Decision Process (MDP) setup represented by the tuple (cid:104) S, A, T, R (cid:105) , where S is the set of all possible state conﬁgurations, A is the set of actions available to the agent, T is the transition distribution, and R is the reward function.
Assuming our dynamics model to be Ω , given the current state s t , we apply our prediction model iteratively:
[Equation]
We then train a policy network to output an action using all these predicted states as context in addition to the current state:
[Equation]
For the policy network, we follow the architecture described in Mnih et al.
and use the
Proximal Policy Optimization (PPO) (Schulman et al., 2017) algorithm for learning from rewards obtained in the task.
We call this framework an Intuitive Physics Agent (IPA).
We update the policy parameters by using the standard
PPO loss,
L ( θ ) =
E [min( r t ( θ ) A t , clip ( r t ( θ ) , 1 − (cid:15), 1 + (cid:15) )
A t ] where r t = π θ ( a t | ˆ s t )
π θ old ( a t | ˆ s t ) and A t is computed using the value function V (ˆ s t ) .
Simultaneously, we also update the parameters of the dynamics model using the same transitions from the environment with the same loss function as in Section 3.1.
Policy gradients are not back-propagated to SpatialNet.
D YNAMICS PREDICTION EXPERIMENTS
We train and evaluate SpatialNet on a variety of 2D environments.
These environments require accurate identiﬁcation of objects and their dynamics for good prediction.
To train our model, we generate videos containing moving objects of various shapes and sizes, complete with acceleration, collisions and other physical phenomena.
Data We generate a video dataset called PhysVideos using the physics engine Pymunk with the included debug renderer (pym).
Our dataset consists of frames of size 84 × 84 × 3 containing moving balls and boxes (Figure 3).
Each frame has 4-8 random moving circles or squares inside a room with 0-3 randomly generated interior walls.
Objects are initialized with friction of 0.9 and elasticity of 0.95, leading to diversity in object movement across a trajectory.
All objects are initialized with random positions and velocities.
Being able to predict the future in this type of environment requires considerable 2-dimensional physics reasoning, such as inferring velocity from past object movement, anticipating changes in momentum due to collisions, and predicting rotations of each object.
We generate 4500 different trajectories for training and 500 trajectories for testing, with each trajectory containing 125 different steps.
We train and evaluate the prediction models using the metric of mean squared error (MSE) on a variety of different domains with varying dynamics.
We use the Adam optimizer (Kingma and Ba, 2015) in our experiments with a learning rate of 10 − 4 .
Baselines We compare our SpatialNet model with a modiﬁed version of the video prediction model of Oh et al.
(2015) which we shall refer to as RCNet which uses convolutional and recurrent networks to encode a sequence of frames in order to predict the next frame.
While their model also makes use of the agent’s action to condition this prediction on, we implement a model without the actionconditioning, i.e. h dect = h enct .
We also compare to the ConvLSTM model of (Xingjian et al., 2015) which uses local LSTMs through convolutions where we use kernel sizes of 5 and identical encoders and decoders to SpatialNet.
Results From Table 1, we see that SpatialNet acheives a much lower test MSE compared to RCNet and ConvLSTM, especially for multi-step predictions.
This suggests that SpatialNet encourages better dynamic generalization compared to RCNet and ConvLSTM.
Qualitatively, in Figure 3, we see that SpatialNet is able to maintain the number of objects in video while RCNet suffers from merging of objects.
In addition, the predictions of SpatialNet appear much more similar to ground Model [Table] 5 step 10 step
Objects Lost (20 step)
RCNet (Oh et al., 2015) 0. [Table] [Table]
[Table]
[Table] [Table]
T+
T+ T+
T+ T+
[Figure]
truth movement even after 20 steps. Further, SpatialNet is able to maintain background details such as walls that are quickly lost in RCNet, as the spatial memory structure allows the input to easily pass ﬁxed background information. We also ﬁnd that spatial memory’s overall structure allows it to be very resistant to input noise – even when Gaussian noise of magnitude 0.5 is added independently to each pixel in test images, SpatialNet achieves a MSE of 0.0062, while RCNet MSE error rises to 0.0268. We provide a table showing sensitivity to random noise in the appendix.
Dataset Generalization.
We test generalization by evaluating on two unseen datasets.
For the ﬁrst, we create a test set where objects are half the size of the training set and initialized randomly with approximately twice the starting velocity.
In this new regime, we found that RCNet had a MSE of 0.0115, ConvLSTM has a MSE of 0.0067, while SpatialNet had a MSE of 0.0039.
We ﬁnd RCNet is unable to maintain shapes of the smaller objects, sometimes omitting them, while ConvLSTM maintains shape but is unable to adapt to new dynamics.
In contrast, SpatialNet local structure allows it to generate new shapes, and its dynamic seperation allows better generalization.
In the second dataset, we explore input size invariance.
We create a second testing data-set consisting 16random circles and squares and input images of size 168x168x3 (the density of objects per area is conserved).
On this dataset, we obtained a MSE of 0.0042 compared to ConvLSTM of 0.0060, which is comparable to the MSE on the original test dataset of 0.0024, showing that the spatial memories local structure allows to easily generalize to different input image sizes.
We show qualitative plots of both datasets in the supplementary.
R EINFORCEMENT L EARNING EXPERIMENTS
In this section, we describe the use of SpatialNet to accelerate reinforcement learning.
We ﬁrst train SpatialNet on the physics video dataset described in the previous section.
Then, we use the pre-trained SpatialNet model as a future frame predictor for a reinforcement learning agent.
We perform empirical evaluations on on two different platforms consisting of 2D games - PhysWorld and a stochastic version of Atari games (Machado et al., 2017a).
We demonstrate that IPA with pre-training outperforms other approaches in both platforms.
The IPA architecture also allows for effective decoupling of environment dynamics from agent policy, which results in better transfer performance across tasks. ∗
5. P HYS W ORLD
The ﬁrst environment we consider is PhysWorld, a new collection of three physics-centric games that we created.
These games require an agent to accurately predict object movements and rotations in order to perform well.
All three tasks have an environment consisting of around 10 randomly moving boxes and circles as well as up to three internal impassable walls.
PhysGoal is a navigation task while having to avoid hitting moving objects, PhysForage is an object gathering task, and PhysShooter requires an agent to shoot selected moving objects while avoiding others.
The objects in each of these environments are different colors and sizes than those used to train the dynamics predictor in
Section 4.
We provide a detailed description of each task in the Appendix (A.2).
We emphasize that the main parameters (like object velocities, rotations,etc.) in the PhysWorld games are fully randomized at the start of each episode.
To obtain good performance, agents to really have a good understanding of general physics and not memorize frames.
Experimental setup.
In our experiments, we use SpatialNet to predict the next k † future frames.
We then stack the current frame with the k predicted frames and use this as input to a model free policy.
We use the Adam optimizer with learning rate 1e-4 to train model predictions and the same set of hyper-parameters for training all policy agents as those used in Schulman et al.
For our policy network, we use the architecture described in Mnih et al.
Baselines.
We compare our model with a number of different baselines.
The ﬁrst baseline is a standard implementation of Proximal Policy Gradient (PPO) (Schulman et al., 2017), which is modelfree and uses the current frame with the last k frames to output an action.
The number of frames provided to PPO is the same as the number provided to IPA.
We also compare with alternative methods to incorporate dynamic models: (1) through value function expansion Feinberg et al.
(2018), which uses a dynamics predictor to obtain a more consistent estimate of the current state’s value, (2) Imagination Augmented Agents (I2A)
Weber et al.
(2017) which uses a combination of past frames and a recurrent encoding of future rollouts as input to the policy, ‡ (3) a model that uses the hidden layer of SpatialNet as input to the policy network (ISP), and (4) a model based on ISP but has an auxiliary frame prediction loss (JISP).
Finally, we also consider baselines where we augment the input to PPO with future frames predicted by either RCNet (Oh et al., 2015) or ConvLSTM (Xingjian et al., 2015).
We report numbers averaged over 3 different random seeds.
[Figure]
Results.
We detail the performance of our approach compared to the baselines in Table 2 and show learning curves in Figure 5.
Quantitatively, we ﬁnd large gains in performance in all three tasks in PhysWorld using IPA with
SpatialNet.
We ﬁnd that IPA with RCNet or ConvLSTM provides less beneﬁts, due to slower learning than SpatialNet.
We also ﬁnd PPO with value expansions also provides slight gains, but signiﬁcantly less than the gains conferred by IPA.
We ﬁnd that I2A leads to no gains in performance, likely due to a global encoding of a image destroying local dynamics information of objects.
We also ﬁnd that both ISP and JISP perform worse than IPA except on PhysForage.
On PhysForage, we ﬁnd that JISP performs better, likely due to increased policy capacity compared to IPA.
IPA encourages the policy to take into account the future physics of objects, a bias crucial for good performance on each of the PhysWorld environments.
Qualitatively, we observe that in all three environments, IPA agents navigate to goals and collect objects with more conﬁdence, even if there are nearby obstacles nearby.
In PhysShooter, IPA agents are much more able to hit objects further away on the map, which require multiple time-steps before collisions.
Figure 4 demonstrates how having a good prior results in faster learning of the environment dynamics of PhysShooter. [Figure] [Table] [Figure]
[Table]
[Figure] environments. In PhysGoal and PhysForage, IPA demonstrates better performance during later stages of training.
In PhysShooter, IPA provides better performance early on because in this game planning is essential since a player can only ﬁre one bullet at a time.
Figure 5 shows the relative training rates of policies under PPO and IPA.
In Phys-Shooter we see immediate beneﬁts in using a physics model, as physics knowledge of the future is crucial as the agent only gets one action approximately every 4-5 frames.
In Phys-Goal and Phys-Forage , we see long term beneﬁts in knowing future physics as this knowledge allows the agents to more efﬁciently collect points.
5. S TOCHASTIC A TARI G AMES
In addition to PhysWorld, we also investigate the performance of IPA on a stochastic version of the
Arcade Learning Environment (ALE) (Bellemare et al., 2013).
The original ALE is fully deterministic (except for random starts) and hence, a dynamics predictor would not provide much value.
We modify
ALE by adding sticky actions , where an agent repeats its last action with probability p = 0 .
This stochasticity was shown to be the most challenging type of randomization to add to ALE (Hausknecht and Stone, 2015; Machado et al., 2017a).
We evaluate performance on all Atari games and in more detail on selected subset of 10 games though we thought had relevant physics features before evaluation. Experiments on all Atari environments were run with 5 seeds.
Results.
On overall performance on all Atari games, we ﬁnd that IPA performs better on 31 games and worse on 18 games as seen in Table 6.
In Table 3, we ﬁnd on our selected games, we observe that IPA outperforms PPO in 8 out of the 10 different tasks.
On worse performing tasks, we found no signiﬁcant degradation.
In several games like Enduro, Breakout, Frostbite, FishingDerby and Assault, IPA provides beneﬁts later on in training after the agent has ﬁgured out a good initial policy.
In others like Asteroids and DemonAttack, IPA provide immediate beneﬁts to training performance, resulting in faster policy learning.
One interesting observation is even with the added stochasticity, the dynamics predictor in the Atari domain obtains a very small MSE of around 0.001 or lower, orders of magnitude smaller than the MSE in PhysWorld environments.
This indicates that the stochastic Atari environments are still relatively deterministic and simpler in terms of dynamics prediction compared to PhysWorld.
We provide additional qualitative results, including frame predictions in the appendix.
5. T RANSFER AND G ENERALIZATION
We now present some empirical results under the transfer scenario and also provide some analysis of our model.
Table 4 also shows the impact of initializing IPA with different pre-trained dynamics models on the PhysShooter environment.
We ﬁnd that initializin SpatialNet with random parameters does not perform very well, but using a pretrained SpatialNet pretrained on PhysVideos provides better performance (see Figure 4 for MSE errors).
Moreover, we observe that transferring a SpatialNet model ﬁne-tuned on a different task like PhysForage/PhysGoal results in even greater performance improvements.
Interestingly, we note that transferring just the dynamics model in IPA results in a larger performance gains than transferring both model and policy .
For instance, transferring the [Table] [Table] model from PhysForage results in a score of 53 . 7 while transferring both model+policy gets a lower score of 40 . 4 .
This provides further evidence that decoupling model learning from policy learning allows for better generalization.
SpatialNet Predictions.
Figure 6 shows the qualitative next 3 frame predictions of SpatialNet on each of the different PhysWorld environment with the ﬁrst frame being the current observation.
In
PhysGoal, SpatialNet is able to infer the movement of the obstacles, the dark blue agent, and the red goal after agent collection.
In PhysGather, SpatialNet is able to infer movement of obstacles as well as the gather of a circle.
In PhysShooter, SpatialNet is able to anticipate a collision of the bullet with a moving obstacle and further infer the shooting of a green bullet by the agent.
Visualization of Spatial Memory.
We provide visualization of the values of spatial memory hidden state while predicting future frames.
We visualize the values of spatial memory on PhysVideos,
PhysGoal and the Atari environment Demon Attack in Figure 7.
To visualize, we take the mean across the channels of each grid pixel in the spatial memory hidden state.
We ﬁnd strong correspondence between high activation regions in the spatial memory and dynamic objects in the associated ground label of the dynamic objects.
We further ﬁnd that static background, such as walls in the input, goals and platforms appear to be passed along in input features.
C ONCLUSION
We have proposed a new approach to model-based reinforcement learning by learning useful physics priors.
First, we pre-train a frame prediction model (SpatialNet) on raw videos of a variety of objects in motion.
We then use this network to initialize a dynamics model for an RL agent, which makes use [Figure] of predicted frames as additional context for its policy.
Through several experiments on two different domains, we demonstrate that our approach outperforms model-free techniques and approaches that learn environment dynamics from scratch.
We also demonstrate the generalizability of our dynamics predictor through transfer learning experiments
A. P HYS W ORLD E NVIRONMENTS
We provide a description of the three games environments in PhysWorld:
PhysGoal:
In this environment, an agent has to navigate to a large red goal.
Each successful navigation (+1 reward) respawns the red goal at a random location while collision with balls or boxes terminates the episode (-1 reward). T+ T+ [Figure]
PhysForage:
Here, an agent has to collect moving balls while avoiding moving boxes.
Each collected ball (+1 reward) will randomly respawn at a new location with a new velocity.
Collision with boxes lead to termination of episode (-1 reward).
PhysShooter:
In PhysShooter, the agent is stationary and has to choose an angle to shoot bullets.
Each bullet travels through the environment until it hits a square (+1 reward) or circle (-1 reward) or leaves the screen.
If a moving ball or box hits the agent (-1 reward), the episode is terminated.
After ﬁring a bullet, the agent cannot ﬁre again until the bullet disappears.
Examples of agents playing the PhysWorld environments are given in Figure 10.
A. A DDITIONAL R EINFORCEMENT L EARNING E XPERIMENTS
Performance on Atari We provide plots of training curves on all Atari environments in Figureon provide on quantitative numbers in Figure 6.
Predictions on Atari We also investigate the beneﬁts (in terms of MSE) of initializing SpatialNet pretrained on the physics dataset compared to training with scratch in Figure 7.
We evaluate the
MSE error at 1 million frames and ﬁnd that initializing with the physics dataset provides a 12.9% decrease in MSE error.
We ﬁnd that pretraining helps on 7 of the 10 Atari environments, with
[Figure]
the most negatively impacted environment being Enduro, a 3D racecar environment in which the environmental prior encoded by the physics dataset may be detrimental.
More signiﬁcant gains in transfer may be achievable by using a large online database of 2D YouTube videos which cover even more of diversity of games.
SpatialNet Predictions We further visualize qualitative results on SpatialNet on training Atari in
Figure 12.
In general, across the Atari Suite, we found that SpatialNet is able to accurately model both the environment and agents behavior.
In the ﬁgure, we seed that SpatialNet is able to accurately [Table] predict agent movement and ice block movement in Frostbite.
On DemonAttack, SpatialNet is able to infer the falling of bullets.
On Asteroid, SpatialNet is able to infer the movement of asteroids.
Finally, on FishingDerby, SpatialNet is able to the right player capturing a ﬁsh and also predict that the left player is likely to catch a ﬁsh (indicated by the blurriness of the rod).
We note that any blurriness in predicted output may in fact even be beneﬁcial to the policy, since policy can learn to interpret the input.
We provide training curves and additional analysis on effects of physics transfer on these environments in the supplementary material. [Table]