yuanming-hu / difftaichi
- четверг, 9 января 2020 г. в 00:18:25
10 differentiable physical simulators built with Taichi differentiable programming (DiffTaichi, ICLR 2020)
Yuanming Hu, Luke Anderson, Tzu-Mao Li, Qi Sun, Nathan Carr, Jonathan Ragan-Kelley, Frédo Durand
[Paper] [Video] (with instructions to reproduce every demo)
The DiffTaichi differentiable programming framework is now officially part of Taichi. This repo only contains examples.
DiffTaichi significantly boosts the performance and productivity of differentiable physical simulators. For example, the differentiable elastic object simulator (ChainQueen) in DiffTaichi is 188x faster than an implementation in TensorFlow. The DiffTaichi version also runs as fast as the CUDA implementation, with the code being 4.2x shorter.
Most of the 10 differentiable simulators can be implemented within 2-3 hours (if you don't consider the coding speed of Yuanming Hu as an outlier...)
Questions regarding the simulators/autodiff compiler go to Yuanming Hu (yuanming at mit.edu) or Issues.
Step 1: Install Taichi with pip:
(Most examples do not need a GPU to run.)
# CPU only. No GPU/CUDA needed. (Linux, OS X and Windows)
python3 -m pip install taichi-nightly
# With GPU (CUDA 10.0) support (Linux only)
python3 -m pip install taichi-nightly-cuda-10-0
# With GPU (CUDA 10.1) support (Linux only)
python3 -m pip install taichi-nightly-cuda-10-1Step 2: Run example scripts in the examples folder: (Please wait for all GIFs to load :-)
python3 diffmpm.py]Gardient descent iteration 0 and gradient descent iteration 80:
python3 diffmpm3d.py]Gradient descent iteration 40:
python3 liquid.py]Gradient descent iteration 450:
python3 wave.py]Gradient descent iteration 180:
python3 water_renderer.py]Differentiable water simulation + differentiable water rendering + (differentiable) CNN
Optimization goal: find an initial water height field, so that after simulation and shading, VGG16 thinks the squirrel image is a goldfish. Input image: VGG16=fox squirrel (42.21%)
Left: center activation . Right: An activation that fools VGG (VGG16=goldfish (99.91%))
python3 rigid_body.py [1/2] train]2048 time steps. Gardient descent iteration 20:
python3 mass_spring.py [1/2/3] train]682 time steps. Gardient descent iteration 20:
python3 billiards.py]Gardient descent iteration 0 and gradient descent iteration 100:
See the video for the remaining two simulators.
@article{hu2019difftaichi,
title={DiffTaichi: Differentiable Programming for Physical Simulation},
author={Hu, Yuanming and Anderson, Luke and Li, Tzu-Mao and Sun, Qi and Carr, Nathan and Ragan-Kelley, Jonathan and Durand, Fr{\'e}do},
journal={arXiv preprint arXiv:1910.00935},
year={2019}
}