end-to-end differentiable physics for learning and control · end-to-end differentiable physics for...

1
End-to-End Differentiable Physics for Learning and Control Filipe de Avila Belbute-Peres 1 , Kevin Smith 2 , Kelsey Allen 2 , Josh Tenenbaum 2 , J. Zico Kolter 13 1. Carnegie Mellon University 2. Massachusetts Institute of Technology 3. Bosch Center for AI Introduction & Motivation § Simulation-based models have strong physical knowledge and learn efficiently, but are inflexible; learned models are flexible, but require extensive (re)training and predictive precision decays fast § We develop a differentiable physics engine, which has both precise knowledge of physics and can be embedded in an end-to-end learning system § Previous similar work have either used numerical differentiation methods or relied solely on auto- differentiation. We propose finding the analytic gradients by differentiating the dynamics equations § This system contributes to a recent trend of incorporating components with structured modules into end-to-end learning systems such as deep networks. § Rigid body dynamics can be framed as a linear complementarity problem (LCP) § Newtonian dynamics represented in terms of velocity, using a discrete time step Dynamics LCP Differentiable physics Parameter learning where: Encode Predict Decode ! " # " ! "$% # "$% § A ball of known mass hits chain. Object positions are observed. Task is inferring the chain mass § The engine’s analytical gradients are more efficient than numerical gradients (finite differences) as number of parameters increase § After observing 3 frames of a billiard ball-like scene, predict positions 10 frames into the future § Physics structure embedded into the model allows for learning with few labeled samples § Since the physics engine is differentiable, we use it in conjunction with iLQR for control in the Cartpole and the Atari Breakout tasks § Simulations are iteratively unrolled starting with an arbitrary mass. Estimated chain mass is minimized using gradient of MSE between the simulated and true positions § Autoencoder architecture. Encoder maps frames into physical predictions. Engine steps physics into the future. Decoder draws image from physics state § Training is performed with only partially labeled data. For unlabeled examples, prediction uses the estimated parameters (notice the hats): § When labels are available, prediction uses the true labels (notice the lack of hats): § Loss is composed of three terms when labels are available, or only the decoder loss when unlabeled § Code available at: https://github.com/locuslab/lcp-physics Control Visual prediction § Parameters are learned from simulations with random policy. Performance is tested as parameters are learned. High reward is achieved before learning a perfect model External resources M ˙ v = f (c) + f M(v t+dt - v t )= dtf (c) t + dtf t § Constraints are added to enforce rigid body dynamics J e λ e =0 (λ c , J c v + c) 2 C (λ f , J f v + E γ ) 2 C (μλ c - E T λ f , γ ) 2 C where C (a, b)= {a 0,b 0,a T b =0} Equality constraints Friction constraints Contact constraints § Equality constraints define joints, contact constraints prevent penetrations and friction constraints define frictional forces § Contact and friction constraints are inequalities and also have a complementarity term (! " #=0), which characterizes the LCP formulation § Solvable via primal-dual interior point method § Optimality conditions for LCP can be written compactly Mx + A T y + G T z + q =0 Ax =0 Gx + Fz + s = m s 0,z 0,s T z 0. § Using matrix differential calculus, we now take the differentials of the system above dMx + Mdx +dA T y + A T dy +dG T z + G T dz +dq =0 dAx + Adx =0 dz (Gx + Fz - m)+ z (dGx + Gdx +dFz + F dz - dm)=0 or in matrix form: § Importantly, since we have already solved the LCP in the forward pass, we can compute the backward pass with just one additional solve based upon the LU-factorization of the LCP matrix § We can effectively differentiate through the simulation at no additional cost to just running the simulation itself § This system is linear in the unknowns ('(, '*, '+), simple to solve for desired differentials § By defining we can derive the gradients

Upload: others

Post on 12-Oct-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: End-to-End Differentiable Physics for Learning and Control · End-to-End Differentiable Physics for Learning and Control Filipe de Avila Belbute-Peres1, Kevin Smith2, Kelsey Allen2,

End-to-End Differentiable Physics for Learning and ControlFilipe de Avila Belbute-Peres1, Kevin Smith2, Kelsey Allen2, Josh Tenenbaum2, J. Zico Kolter13

1. Carnegie Mellon University 2. Massachusetts Institute of Technology 3. Bosch Center for AI

Introduction & Motivation§ Simulation-based models have strong physical

knowledge and learn efficiently, but are inflexible; learned models are flexible, but require extensive (re)training and predictive precision decays fast

§ We develop a differentiable physics engine, which has both precise knowledge of physics and can be embedded in an end-to-end learning system

§ Previous similar work have either used numerical differentiation methods or relied solely on auto-differentiation. We propose finding the analytic gradients by differentiating the dynamics equations

§ This system contributes to a recent trend of incorporating components with structured modules into end-to-end learning systems such as deep networks.

§Rigid body dynamics can be framed as a linear complementarity problem (LCP)

§Newtonian dynamics represented in terms of velocity, using a discrete time step

Dynamics LCP

Differentiable physics Parameter learning

where:

Encode Predict Decode!"#"

!"$%#"$%

§ A ball of known mass hits chain. Object positions are observed. Task is inferring the chain mass

§ The engine’s analytical gradients are more efficient than numerical gradients (finite differences) as number of parameters increase

§ After observing 3 frames of a billiard ball-like scene, predict positions 10 frames into the future

§ Physics structure embedded into the model allows for learning with few labeled samples

§ Since the physics engine is differentiable, we use it in conjunction with iLQR for control in the Cartpole and the Atari Breakout tasks

§ Simulations are iteratively unrolled starting with an arbitrary mass. Estimated chain mass is minimized using gradient of MSE between the simulated and true positions

§ Autoencoder architecture. Encoder maps frames into physical predictions. Engine steps physics into the future. Decoder draws image from physics state

§ Training is performed with only partially labeled data. For unlabeled examples, prediction uses the estimated parameters (notice the hats):

§ When labels are available, prediction uses the true labels (notice the lack of hats):

§ Loss is composed of three terms when labels are available, or only the decoder loss when unlabeled

§Code available at: https://github.com/locuslab/lcp-physics

Control

Visual prediction

§ Parameters are learned from simulations with random policy. Performance is tested as parameters are learned. High reward is achieved before learning a perfect model

External resources

Mv̇ = f (c) + f<latexit sha1_base64="8sCk7yA1M48TcNzWFmiJ/DlANXg=">AAACCnicbVC7SgNBFL3rM8bXqqXNaAhEhLCrhTZCwMZGiGAekKxhdjKbDJl9MDMbCMuCnYX+io2FIrZ+gZ1/42ySQhMPDBzOuffOvceNOJPKsr6NhcWl5ZXV3Fp+fWNza9vc2a3LMBaE1kjIQ9F0saScBbSmmOK0GQmKfZfThju4zPzGkArJwuBWjSLq+LgXMI8RrLTUMQ/aPlZ9gnlynaJ2N1TJMEUXyLtLSuQoRcfI65gFq2yNgeaJPSWFymnx8R4Aqh3zS88hsU8DRTiWsmVbkXISLBQjnKb5dixphMkA92hL0wD7VDrJ+JQUFbXSRV4o9AsUGqu/OxLsSznyXV2ZLS5nvUz8z2vFyjt3EhZEsaIBmXzkxRypEGW5oC4TlCg+0gQTwfSuiPSxwETp9PI6BHv25HlSPynbmt/oNJowQQ724RBKYMMZVOAKqlADAg/wDK/wZjwZL8a78TEpXTCmPXvwB8bnD5pbmxQ=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0NRyes0c46/IL18Q2ABaJ9</latexit><latexit sha1_base64="OxdV1bVZHibXo8Av5xZALIQ7re4=">AAACHnicbVDLSgMxFM3UV62vqks3QRFaimVGELsRCm7cCApWC20dMplMG5p5kNwp1GG2/oQbf8WNC0UEV7r1S8y0XWjrgcDJOfeSnONEgiswzS8jNze/sLiUXy6srK6tbxQ3t65VGEvKGjQUoWw6RDHBA9YADoI1I8mI7wh24/RPM/9mwKTiYXAFw4h1fNINuMcpAS3ZxSPc9gn0KBHJeYpLAzuBigspPsADG8r4BLuAPRtukxItp7gyudrFPbNqjoBniTUhe/Xa3fe9jHsXdvGj7YY09lkAVBClWpYZQSchEjgVLC20Y8UiQvuky1qaBsRnqpOM4qV4Xysu9kKpTwB4pP7eSIiv1NB39GSWRU17mfif14rBq3USHkQxsICOH/JigSHEWVfY5ZJREENNCJVc/xXTHpGEgm60oEuwpiPPkuvDqqX5pW6jicbIox20i0rIQseojs7QBWogih7QE3pBr8aj8Wy8Ge/j0Zwx2dlGf2B8/gBHx6PS</latexit><latexit sha1_base64="OxdV1bVZHibXo8Av5xZALIQ7re4=">AAACHnicbVDLSgMxFM3UV62vqks3QRFaimVGELsRCm7cCApWC20dMplMG5p5kNwp1GG2/oQbf8WNC0UEV7r1S8y0XWjrgcDJOfeSnONEgiswzS8jNze/sLiUXy6srK6tbxQ3t65VGEvKGjQUoWw6RDHBA9YADoI1I8mI7wh24/RPM/9mwKTiYXAFw4h1fNINuMcpAS3ZxSPc9gn0KBHJeYpLAzuBigspPsADG8r4BLuAPRtukxItp7gyudrFPbNqjoBniTUhe/Xa3fe9jHsXdvGj7YY09lkAVBClWpYZQSchEjgVLC20Y8UiQvuky1qaBsRnqpOM4qV4Xysu9kKpTwB4pP7eSIiv1NB39GSWRU17mfif14rBq3USHkQxsICOH/JigSHEWVfY5ZJREENNCJVc/xXTHpGEgm60oEuwpiPPkuvDqqX5pW6jicbIox20i0rIQseojs7QBWogih7QE3pBr8aj8Wy8Ge/j0Zwx2dlGf2B8/gBHx6PS</latexit><latexit sha1_base64="E9SlMrFz4ZphssPDKwQPAHDyoas=">AAACHnicbVDLSgMxFM3UV62vqks3wSK0FMuMILoRCm7cCBXsA9o6ZDKZNjTzILlTKMN8iRt/xY0LRQRX+jem7Sy09UDg5Jx7Sc5xIsEVmOa3kVtZXVvfyG8WtrZ3dveK+wctFcaSsiYNRSg7DlFM8IA1gYNgnUgy4juCtZ3R9dRvj5lUPAzuYRKxvk8GAfc4JaAlu3iOez6BISUiuU1xeWwnUHUhxad4bEMFX2EXsGfDQ1KmlRRXs6tdLJk1cwa8TKyMlFCGhl387LkhjX0WABVEqa5lRtBPiAROBUsLvVixiNARGbCupgHxmeons3gpPtGKi71Q6hMAnqm/NxLiKzXxHT05zaIWvan4n9eNwbvsJzyIYmABnT/kxQJDiKddYZdLRkFMNCFUcv1XTIdEEgq60YIuwVqMvExaZzVL8zuzVO9kdeTRETpGZWShC1RHN6iBmoiiR/SMXtGb8WS8GO/Gx3w0Z2Q7h+gPjK8fW3qgKQ==</latexit>

§Constraints are added to enforce rigid body dynamics

Je�e = 0

(�c,Jcv + c) 2 C(�f ,Jfv + E�) 2 C

(µ�c � ET�f , �) 2 Cwhere C(a, b) = {a � 0, b � 0, aT b = 0}

<latexit sha1_base64="TUinc01OfHtcdmf2yk2TvVxJu0A=">AAAC/nicfVJNixNBEO0Zv9b4lVVvXgqDksW4zIigF2FhWRBPKyS7gUw21HRqkma7Z8buntUwDPhXvHhQxKu/w5v/xp7sqMmuWtDw+r161VXdHedSGBsEPzz/wsVLl69sXG1du37j5q325u0DkxWa04BnMtPDGA1JkdLACitpmGtCFUs6jI93a/3whLQRWdq3i5zGCmepSARH66jJpnc3UmjnHGX5qpoQRNJ5p+jQQ3gBAURRq/uL4z1YTeZwAo+Ab7nMSKR/pN1qzZWsu5Klay+aoVL4T68qfnfC4fHeUX+12v+skaV3tnw7J01QrYpd7MVbbqSoBHQl6A0EPYjrIg3Go77bL2euJu1OsB0sA86DsAEd1sT+pP09mma8UJRaLtGYURjkdlyitoJLqlpRYShHfowzGjmYoiIzLpfPV8EDx0whybRbqYUlu+ooURmzULHLrOcxZ7Wa/Js2KmzyfFyKNC8spfz0oKSQYDOo/wJMhSZu5cIB5Fq4XoHPUSO37se03CWEZ0c+Dw6ebIcOv37a2Rk217HB7rH7rMtC9oztsJdsnw0Y90rvg/fJ++y/9z/6X/yvp6m+13jusLXwv/0EI7XnVA==</latexit><latexit sha1_base64="TUinc01OfHtcdmf2yk2TvVxJu0A=">AAAC/nicfVJNixNBEO0Zv9b4lVVvXgqDksW4zIigF2FhWRBPKyS7gUw21HRqkma7Z8buntUwDPhXvHhQxKu/w5v/xp7sqMmuWtDw+r161VXdHedSGBsEPzz/wsVLl69sXG1du37j5q325u0DkxWa04BnMtPDGA1JkdLACitpmGtCFUs6jI93a/3whLQRWdq3i5zGCmepSARH66jJpnc3UmjnHGX5qpoQRNJ5p+jQQ3gBAURRq/uL4z1YTeZwAo+Ab7nMSKR/pN1qzZWsu5Klay+aoVL4T68qfnfC4fHeUX+12v+skaV3tnw7J01QrYpd7MVbbqSoBHQl6A0EPYjrIg3Go77bL2euJu1OsB0sA86DsAEd1sT+pP09mma8UJRaLtGYURjkdlyitoJLqlpRYShHfowzGjmYoiIzLpfPV8EDx0whybRbqYUlu+ooURmzULHLrOcxZ7Wa/Js2KmzyfFyKNC8spfz0oKSQYDOo/wJMhSZu5cIB5Fq4XoHPUSO37se03CWEZ0c+Dw6ebIcOv37a2Rk217HB7rH7rMtC9oztsJdsnw0Y90rvg/fJ++y/9z/6X/yvp6m+13jusLXwv/0EI7XnVA==</latexit><latexit sha1_base64="TUinc01OfHtcdmf2yk2TvVxJu0A=">AAAC/nicfVJNixNBEO0Zv9b4lVVvXgqDksW4zIigF2FhWRBPKyS7gUw21HRqkma7Z8buntUwDPhXvHhQxKu/w5v/xp7sqMmuWtDw+r161VXdHedSGBsEPzz/wsVLl69sXG1du37j5q325u0DkxWa04BnMtPDGA1JkdLACitpm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>

Equality constraints

Friction constraints

Contact constraints

§ Equality constraints define joints, contact constraints prevent penetrations and friction constraints define frictional forces

§Contact and friction constraints are inequalities and also have a complementarity term (!"# = 0), which characterizes the LCP formulation

§ Solvable via primal-dual interior point method

§Optimality conditions for LCP can be written compactly

Mx+AT y +GT z + q = 0

Ax = 0

Gx+ Fz + s = m

s � 0, z � 0, sT z � 0.<latexit sha1_base64="emACVWUvW1W/D/ktUg3S3+XQ2o4=">AAACXHicbVHLSgMxFM2MVfvwMSq4cXOxKIJSZkTQjaAI1o1QodVCp5ZMmrahmYdJRqxDf9KdG39FM9Pio/VCuOeee24eJ17EmVS2/W6YC7nFpeV8oVhaWV1btzY272UYC0IbJOShaHpYUs4C2lBMcdqMBMW+x+mDN7xK+w/PVEgWBnU1imjbx/2A9RjBSlMdS7o+VgOCeXI7hhc4hMvHOox0rur8qvMT7MM52OC6xUst+C6qmfo6lciM9VNWgtunT2AfuXp4/6eQ2W6TstKxynbFzgLmgTMFZTSNWsd6c7shiX0aKMKxlC3HjlQ7wUIxwum46MaSRpgMcZ+2NAywT2U7ycwZw55mutALhV6Bgoz9PZFgX8qR72llaoWc7aXkf71WrHpn7YQFUaxoQCYH9WIOKoTUaegyQYniIw0wEUzfFcgAC0yU/o+iNsGZffI8uD+uOBrfnZQvmlM78mgH7aID5KBTdIFuUA01EEHv6NPIGwXjw8yZJXN1IjWN6cwW+hPm9he8+qkx</latexit><latexit sha1_base64="emACVWUvW1W/D/ktUg3S3+XQ2o4=">AAACXHicbVHLSgMxFM2MVfvwMSq4cXOxKIJSZkTQjaAI1o1QodVCp5ZMmrahmYdJRqxDf9KdG39FM9Pio/VCuOeee24eJ17EmVS2/W6YC7nFpeV8oVhaWV1btzY272UYC0IbJOShaHpYUs4C2lBMcdqMBMW+x+mDN7xK+w/PVEgWBnU1imjbx/2A9RjBSlMdS7o+VgOCeXI7hhc4hMvHOox0rur8qvMT7MM52OC6xUst+C6qmfo6lciM9VNWgtunT2AfuXp4/6eQ2W6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MT7MM52OC6xUst+C6qmfo6lciM9VNWgtunT2AfuXp4/6eQ2W6TstKxynbFzgLmgTMFZTSNWsd6c7shiX0aKMKxlC3HjlQ7wUIxwum46MaSRpgMcZ+2NAywT2U7ycwZw55mutALhV6Bgoz9PZFgX8qR72llaoWc7aXkf71WrHpn7YQFUaxoQCYH9WIOKoTUaegyQYniIw0wEUzfFcgAC0yU/o+iNsGZffI8uD+uOBrfnZQvmlM78mgH7aID5KBTdIFuUA01EEHv6NPIGwXjw8yZJXN1IjWN6cwW+hPm9he8+qkx</latexit>

§Using matrix differential calculus, we now take the differentials of the system above

dMx+Mdx+ dAT y +ATdy + dGT z +GTdz + dq = 0

dAx+Adx = 0

dz � (Gx+ Fz �m) + z � (dGx+Gdx+ dFz + Fdz � dm) = 0<latexit sha1_base64="5YyhWlspzUmKFMRWejrKjjnNSdY=">AAADi3icfVJdb9MwFHUTPkpgrBuPvFxRbRqCVQkgbZpA2oRoeUEa0rpVqkvlOG5nzfmY7SDSKD+Gv8Qb/wYnCyjNJq5k5dxzjnWPHfuJ4Eq77u+OZd+7/+Bh95Hz+MnG083e1va5ilNJ2ZjGIpYTnygmeMTGmmvBJolkJPQFu/CvPpb6xXcmFY+jM50lbBaSZcQXnBJtqPlW52eOQ6IvZZgHRVFBSkT+pYAf8AqafdNXas3+5NsZZIYrv00+a/lGRl8ZbtTyrVq+a9iFD+ACxs7amCrUSSvKndYVYMolhb1RtWdoxu5D+NLAf8pasMo1+u8hh1X0YSv4/lpvJlRxHDC1A9hfEMBLdg3ua2y6MMfC/JuAFHP6lwdc2cyNtPTd2jHv9d2BWxXcBl4N+qiu03nvFw5imoYs0lQQpaaem+hZTqTmVLDCwaliCaFXZMmmBkYkZGqWV2+pgB3DBLCIpVmRhopt7shJqFQW+sZZHlu1tZK8S5umenE4y3mUpJpF9GbQIhWgYygfJgRcMqpFZgChkpusQC+JJFSb5+uYS/DaR74Nzt8MPIO/vusfT+rr6KLn6AXaQx46QMfoMzpFY0StrjWw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olhb1RtWdoxu5D+NLAf8pasMo1+u8hh1X0YSv4/lpvJlRxHDC1A9hfEMBLdg3ua2y6MMfC/JuAFHP6lwdc2cyNtPTd2jHv9d2BWxXcBl4N+qiu03nvFw5imoYs0lQQpaaem+hZTqTmVLDCwaliCaFXZMmmBkYkZGqWV2+pgB3DBLCIpVmRhopt7shJqFQW+sZZHlu1tZK8S5umenE4y3mUpJpF9GbQIhWgYygfJgRcMqpFZgChkpusQC+JJFSb5+uYS/DaR74Nzt8MPIO/vusfT+rr6KLn6AXaQx46QMfoMzpFY0StrjWwDqxDe8N+ax/Z72+sVqfe8wytlf3pD1EnGXc=</latexit><latexit sha1_base64="5YyhWlspzUmKFMRWejrKjjnNSdY=">AAADi3icfVJdb9MwFHUTPkpgrBuPvFxRbRqCVQkgbZpA2oRoeUEa0rpVqkvlOG5nzfmY7SDSKD+Gv8Qb/wYnCyjNJq5k5dxzjnWPHfuJ4Eq77u+OZd+7/+Bh95Hz+MnG083e1va5ilNJ2ZjGIpYTnygmeMTGmmvBJolkJPQFu/CvPpb6xXcmFY+jM50lbBaSZcQXnBJtqPlW52eOQ6IvZZgHRVFBSkT+pYAf8AqafdNXas3+5NsZZIYrv00+a/lGRl8ZbtTyrVq+a9iFD+ACxs7amCrUSSvKndYVYMolhb1RtWdoxu5D+NLAf8pasMo1+u8hh1X0YSv4/lpvJlRxHDC1A9hfEMBLdg3ua2y6MMfC/JuAFHP6lwdc2cyNtPTd2jHv9d2BWxXcBl4N+qiu03nvFw5imoYs0lQQpaaem+hZTqTmVLDCwaliCaFXZMmmBkYkZGqWV2+pgB3DBLCIpVmRhopt7shJqFQW+sZZHlu1tZK8S5umenE4y3mUpJpF9GbQIhWgYygfJgRcMqpFZgChkpusQC+JJFSb5+uYS/DaR74Nzt8MPIO/vusfT+rr6KLn6AXaQx46QMfoMzpFY0StrjWwDqxDe8N+ax/Z72+sVqfe8wytlf3pD1EnGXc=</latexit>

or in matrix form:

§ Importantly, since we have already solved the LCP in the forward pass, we can compute the backward pass with just one additional solve based upon the LU-factorization of the LCP matrix

§We can effectively differentiate through the simulation at no additional cost to just running the simulation itself

§This system is linear in the unknowns ('(, '*, '+), simple to solve for desired differentials

§By defining

we can derive the gradients