From Program to Sketch: Modeling Non-Deterministic Observations in Code Generation

From Program to Sketch: Modeling Non-Deterministic Observations in Code Generation


Abstract and 1. Introduction

  1. Background & Related Work

  2. Method

    3.1 Sampling Small Mutations

    3.2 Policy

    3.3 Value Network & Search

    3.4 Architecture

  3. Experiments

    4.1 Environments

    4.2 Baselines

    4.3 Ablations

  4. Conclusion, Acknowledgments and Disclosure of Funding, and References

    \

Appendix

A. Mutation Algorithm

B. Context-Free Grammars

C. Sketch Simulation

D. Complexity Filtering

E. Tree Path Algorithm

F. Implementation Details

C Sketch Simulation

As mentioned in the main text, we implement the CSG2D-Sketch environment, which is the same as CSG2D with a hand-drawn sketch observation model. We do this to primarily show how this sort of a generative model can possibly be applied to a real-world task, and that observations do not need to

\
Figure 11: Examples of thresholding scene images using the LZ4 compression algorithm. The left represents our test set, the right represents our training distribution.

\
be deterministic. Our sketch algorithm can be found in our codebase, and is based off the approach described in Wood et al. [39].

\
Our compiler uses Iceberg [16] and Google’s 2D Skia library to perform boolean operations on primitive paths. The resulting path consists of line and cubic bézier commands. We post-process these commands to generate sketches. For each command, we first add Gaussian noise to all points stated in those commands. For each line, we randomly pick a point near the 50% and 75% of the line, add Gaussian noise, and fit a Catmull-Rom spline [5]. For all curves, we sample random points at uniform intervals and fit Catmull-Rom splines. We have a special condition for circles, where we ensure that the start and end points are randomized to create the effect of the pen lifting off. Additionally we randomize the stroke thickness.

\
Figure 10 shows the same program rendered multiple times using our randomized sketch simulator.

\

:::info
Authors:

(1) Shreyas Kapur, University of California, Berkeley (srkp@cs.berkeley.edu);

(2) Erik Jenner, University of California, Berkeley (jenner@cs.berkeley.edu);

(3) Stuart Russell, University of California, Berkeley (russell@cs.berkeley.edu).

:::


:::info
This paper is available on arxiv under CC BY-SA 4.0 DEED license.

:::

\



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *