Sub topic 10
Shaping new behavior by successive approximations
This chapter assumes you know the four consequence types (positive and negative reinforcement, positive and negative punishment). It also assumes you know what extinction is and why a reinforcer's value depends on motivation. If those are unfamiliar, review the earlier chapters first.
The problem shaping solves
Reinforcement can only strengthen a behavior that happens. Suppose you want a rat to press a lever, a child to say a new word, or a patient to walk the length of a hallway after surgery. If the behavior never occurs, you have nothing to reinforce.
You could wait. Waiting can take hours, and it may never work. Shaping is the alternative. It is the differential reinforcement of successive approximations to a target behavior. The target behavior is the final response you want. An approximation is any behavior that resembles the target to some degree. Shaping reinforces the closest approximations that currently occur. Then it gradually requires more.
Shaping combines two processes you already know:
- Reinforcement strengthens the approximations that are reinforced.
- Extinction weakens the earlier, cruder approximations once they stop paying off.
Another effect makes shaping work. Behavior varies from one attempt to the next, and reinforcing one version also produces more variation around it. Some of those new variations are slightly closer to the target. Those become the next ones to reinforce.
Worked example: teaching a rat to press a lever
Imagine a rat in a chamber with a lever on one wall. A food pellet dispenser is nearby. The rat has not been fed for a few hours, so food is an effective reinforcer. First, the rat has learned that the click of the dispenser predicts food, so the click itself works as a conditioned reinforcer.
A trainer might proceed like this:
- Reinforce any movement toward the side of the chamber with the lever.
- Reinforce only when the rat faces the lever.
- Reinforce only when the rat is within a body length of the lever.
- Reinforce only when the rat touches the lever with a paw.
- Reinforce only when the rat pushes the lever down far enough to register.
At each step the old criterion is no longer reinforced. Merely walking toward the wall now goes unreinforced. This is extinction of the earlier approximation, and it is what pushes the animal to try something closer.
Key terms
| Term | Meaning |
|---|---|
| Target behavior | The final response you want to build. |
| Approximation | A response that partly resembles the target. |
| Criterion | The current standard a response must meet to be reinforced. |
| Differential reinforcement | Reinforcing some responses and not others. |
| Conditioned reinforcer | A neutral stimulus (such as a click) that gained value by being paired with a reinforcer. |
Shaping as an algorithm
You can see the logic of shaping in a short simulation. The learner below produces responses with some random variation around an average. The shaper reinforces any response that meets the current criterion. Reinforcement shifts the average toward the response that was reinforced. When the learner meets the criterion often enough, the criterion moves closer to the target.
import random
def shape(target=10.0, start=0.0, step=1.0, seed=3):
"""Shape a numeric 'behavior' toward target by raising a criterion."""
random.seed(seed)
mean = start # the learner's typical response
criterion = start + step
hits = 0
trials = 0
while mean < target - 0.5 and trials < 5000:
trials += 1
response = random.gauss(mean, 1.0) # behavior varies around its mean
if response >= criterion: # meets the current standard
mean += 0.3 * (response - mean) # reinforced behavior becomes more likely
hits += 1
if hits >= 5: # reliably meeting criterion: raise the bar
criterion = min(criterion + step, target)
hits = 0
return trials, round(mean, 2)
trials, final_mean = shape()
print(trials, final_mean)The code shows three things that matter in real training:
- Behavior varies. Without variation, there would be nothing new to reinforce.
- Only responses at or above the criterion are reinforced, so earlier responses are effectively on extinction.
- The criterion moves only after the learner succeeds reliably.
Rules of thumb for good shaping
Define the target precisely
You cannot shape well toward "better behavior." Specify what the response looks like, how often, and where. "Raises hand and waits to be called on" is a target. "Participates more" is not.
Start where the learner is
The first approximation must be something the learner already does. If nothing resembles the target yet, choose a broader starting point, such as orienting toward the lever, and reinforce that.
Deliver reinforcement immediately
Reinforcement works best when it follows the response within about a second or so. Delays let other behaviors occur in between, and those get reinforced instead. This is why animal trainers use a click or a whistle. A bridge signal marks the exact moment of the correct response, even if the food arrives a moment later.
Move in small steps
If the steps are too large, the learner stops earning reinforcement. Extinction then sets in for the current behavior, and the learner may show an extinction burst (a temporary increase in the old behavior and in variability), frustration, or give up. If the steps are too small, progress is slow and the learner can get stuck at an approximation.
Do not reinforce the same approximation forever
If you keep reinforcing one approximation, you strengthen it. This is a common reason shaping stalls. The learner repeats a response that is good enough to be paid and has no reason to vary. The fix is to raise the criterion.
Let the learner's performance set the pace
Move on when the current approximation is happening reliably, not on a fixed schedule. If performance drops after you raise the criterion, go back one step, reinforce generously, and try a smaller increase.
Common errors
| Error | What happens | Fix |
|---|---|---|
| Criterion raised too fast | Reinforcement drops, behavior falls apart, frustration appears | Return to the last successful step and use smaller increments |
| Criterion raised too slowly | Learner gets stuck repeating a crude approximation | Raise the criterion once responding is reliable |
| Reinforcer delayed | Unrelated behavior gets strengthened | Use an immediate marker such as a click |
| Reinforcer not motivating | Little responding to shape | Check motivation and choose a more effective reinforcer |
| Unclear target | Trainer reinforces inconsistently | Write down the target and each approximation in advance |
| Accidental shaping | Unwanted behavior gets built | Review what actually follows the behavior |
Shaping unwanted behavior by accident
Shaping does not need a trainer. Any time reinforcement is given inconsistently for gradually stronger versions of a behavior, shaping occurs.
Consider a child who asks quietly for attention. A busy parent ignores a quiet request but responds when the child is louder. The child escalates to a loud request, and that gets attention. Over days, the parent responds only to yelling. The parent has shaped yelling, though neither person intended it.
Shaping, chaining, and prompting
Shaping is often confused with related techniques.
- Shaping builds a new response by reinforcing changing approximations of one behavior.
- Chaining links several already-learned responses into a sequence, with each response producing the cue for the next.
- Prompting helps a behavior occur by giving a hint or physical guide, then fading it. It does not wait for the behavior to appear on its own.
Real training often combines them. A dog trainer may shape a paw touch on a target, then chain it with other responses, then fade the prompts.
Limits of shaping
Shaping needs variation and some starting behavior. It is slow when the learner is unmotivated, when reinforcement cannot be delivered quickly, or when the trainer cannot observe the behavior closely. For complex human skills, language instructions and modeling are usually faster than pure shaping. Shaping remains useful when instructions are not enough, such as with young children, animals, or people relearning movement after injury.
Exercise
A trainer is shaping a dog to roll over. The dog lies down reliably, so the trainer keeps giving a treat for lying down only. After 20 minutes, the dog lies down every time but never tries anything else. What went wrong, and what should the trainer do?
Show answer
The trainer kept reinforcing one approximation (lying down) and never raised the criterion, so the dog had no reason to vary. The trainer should stop reinforcing plain lying down and reinforce only a closer approximation, such as lying down and tipping onto one hip. Then the trainer can raise the standard again, step by step, toward a full roll.
Exercise
A learner shaped to reach a criterion suddenly stops responding after the trainer jumps three steps ahead. Name the process that likely explains this and give one way to recover.
Show answer
The previously reinforced responses no longer meet the criterion, so reinforcement stops and extinction sets in, possibly with an extinction burst and frustration. To recover, return to the last criterion the learner met reliably, reinforce it generously, and then raise the criterion in smaller steps.