Code
Code
Two right answers
The machine is the Newton simulation of the claw machine used throughout this chapter: the squares are rigid boxes under gravity, and a released box falls over a few control steps and can slide. The floor holds two squares, both of the color the instruction names, at least 0.35 apart. The instruction asks for “a” red square, and delivering either square earns reward 1. With no square of another color, the policy never has to tell colors apart to pick a correct square. Slips are switched off. The claw starts midway between the two squares, at a random height. The operator decides at the start of each episode which square to fetch, with equal probability, and moves toward it. It aims at the square’s center with an error of at most 0.015, so a few of its catches fail and the demonstrations also show the recovery: open, rise one step and try again.Code
Code
Action chunks
Three of the heads predict an action chunk per query, as defined in Action representations II: regression and chunks: a chunk of length , of which the policy executes the first actions before it looks at the camera again. Here and . Each action is rescaled to : the two moves in units of the largest step, and the grip as (open) or (closed).Code
Code
One backbone, different heads
Every policy uses the MiniVLA backbone of the behavioral cloning section: FiLM-conditioned convolutions and a small transformer that reduce the image and the instruction to a summary vector . The backbone is trained once, end to end with the token head, and then frozen. Each head is trained on the frozen of the demonstration steps, which plays the role of a pretrained VLA backbone with a new action head on top. All heads get the same 20,000 training steps.Code
Code
Five ways to turn into an action
The regression head is a perceptron trained with the squared error on the next action. For an observation , the function that minimizes the expected squared error is the conditional mean, At the start state half the demonstrations move left and half move right, so the conditional mean of the first move is zero, a move that no demonstration makes. The token head is the one from the behavioral cloning section: , and the grip become three tokens, and the head outputs a categorical distribution over each, conditioned on the tokens before it. A categorical distribution can put its mass on two separate bins. Taking the most likely token picks one of them; sampling can pick either. The conditional VAE follows ACT. An encoder compresses the demonstrated chunk into a latent , and a decoder maps back to a chunk. Training minimizes The latent can carry the operator’s choice, which the start image cannot. ACT uses the L1 error, weights the KL term with , discards the encoder after training and sets to the prior mean, zero, at test time (Zhao et al., 2023). You run that variant, and one that draws from the prior. The VAE architecture section derives the same objective for images. The diffusion head follows Diffusion Policy, which uses a DDPM (Chi et al., 2023; Ho et al., 2020). Write for a demonstrated chunk, flattened, and for the diffusion step, so that it does not clash with the time step . The forward process adds Gaussian noise in the closed form of the DDPM section, and a network learns to predict the noise with the loss . Sampling starts from pure noise and runs denoising steps. Different starting noise ends in different chunks, so the head can return either choice. You run it with chunks and with single actions (). The flow-matching head uses the straight path of the flow matching section. With flow time , noise and a demonstrated chunk , and a network learns the velocity with a squared error. Sampling integrates from noise in 10 Euler steps. Like diffusion, it maps different noise to different chunks.Code
Code
Training and rollouts
The code below trains the backbone and the heads, and runs a policy on a batch of machines. A policy that returns a chunk executes its first four actions and then queries again. The rollout records whether a square was delivered and which way the claw went in its first ten steps.Code
Code
Delivery and choice
Each policy runs on 20 layouts, 16 times per layout, with fresh grasp outcomes and fresh samples on every run. The table reports the delivery rate over the 320 episodes. It also reports how often both squares were chosen across the 16 runs of a layout, and the minority share: the fraction of runs that went to the less chosen square, averaged over layouts. A policy that splits evenly on every layout has a minority share of 0.5.Code
Code
What the heads did
Delivery does not separate the heads much. Regression delivers 0.93 of the episodes, and most of the other heads between 0.73 and 0.90. With 320 episodes per policy, differences of a few points are within the evaluation noise. Delivery also moves between training runs. In an earlier run of the same code, the delivery of single heads changed by more than ten points, while the choice of square did not, so the table does not rank the heads by delivery. Most failures come from the physics of the grab: a square released outside the chute, or catches that fail repeatedly. The chunked diffusion head is lowest at 0.65. It executes four actions without looking, and its moves are less precise than those of the closed-loop heads, so more of its catches land off center. The square each head chose separates them more clearly. Regression, greedy tokens and the conditional VAE always went to the same square on a given layout. Diffusion and flow matching went to both squares on 85% to 100% of the layouts, and sampled tokens on 25%. None of the generative heads split evenly: the minority share of diffusion and flow matching is 0.25 to 0.31, and that of sampled tokens 0.04, against 0.5 for the operator. Regression did not get stuck midway, although its training target at the start state is a zero move. Its first moves in the histogram are spread between the two modes, and many are far from zero. Each training layout contributes one start state with one direction, so the network does not see the even split on any single layout, and on a new layout it returns some value between the modes. It is rarely exactly zero, and one move away from the midpoint, the image belongs to one of the two choices, and the regression head follows it. The midway point is an unstable balance, and in this task the averaged action costs little. When the two choices stay ambiguous for many steps, as when a robot can pass an obstacle on either side, the conditional mean points between them for as long as the ambiguity lasts. The conditional VAE ignored its latent. Drawing from the prior gives the same first moves and the same choices as setting it to zero, so the decoder learned to predict the chunk from alone. On the layout in the paths figure, both variants sent all 16 runs to the right square, and none of them delivered. ACT notes that a larger transmits less information through (Zhao et al., 2023). With and demonstrations whose only variation is one binary choice, the KL term made it cheaper to ignore . ACT motivates the CVAE with noisy human demonstrations, and reports the objective as essential for learning precise tasks from them. Diffusion with single actions can switch modes between steps, because each step draws fresh noise. In the paths above, most of its runs keep the direction of their first move, since after one move the image no longer looks like the start. Chunks commit to a choice for steps by construction, which is how Diffusion Policy keeps one mode within a rollout in its Push-T example (Chi et al., 2023). The heads also differ in cost per action. Diffusion with single actions runs the denoiser 50 times per executed action, and the chunked version 12.5 times, since each query of 50 steps yields four actions. Flow matching needs 2.5 velocity evaluations per action, and the conditional VAE one decoder pass per four actions. Diffusion Policy reduces this cost with DDIM, training with 100 diffusion steps and sampling with 10 (Chi et al., 2023). These results come from one task, one scripted operator whose two modes are clean, and heads that were not tuned individually. The backbone was trained with the token loss, which may favor the token head. The minority shares come from 16 runs per layout, so each layout’s share has a standard error of about 0.12, and only the average over 20 layouts is stable.References
- Chi, C., Xu, Z., Feng, S., Cousineau, E., Du, Y., et al. (2023). Diffusion Policy: Visuomotor policy learning via action diffusion. arXiv [cs.RO]. Link
- Ho, J., Jain, A., Abbeel, P. (2020). Denoising Diffusion Probabilistic Models. arXiv [cs.LG]. DOI
- Lipman, Y., Chen, R., Ben-Hamu, H., Nickel, M., Le, M. (2022). Flow Matching for generative modeling. arXiv [cs.LG]. Link
- Zhao, T., Kumar, V., Levine, S., Finn, C. (2023). Learning fine-grained bimanual manipulation with low-cost hardware. arXiv [cs.RO]. DOI
Found an error on this page? Report an issue.

