Example 03 · RNN · GRU · LSTM

Fall Detection

Fall detection for pendants and smartwatches, running nonstop on a battery-powered microcontroller. We trained three kinds of recurrent network to spot the free fall, impact and stillness of a fall, and in 60 training runs, every one caught every simulated test fall without a single false alarm.

A person wearing a pendant on a lanyard: standing during everyday activity with acceleration steady near 1 g, falling with a free fall and an impact, then lying on the floor while the pendant raises an alert. An inset shows the pendant's contents: a 3-axis accelerometer, a microcontroller running a 16-unit recurrent network, a battery and a radio.
A fall-detection pendant. The accelerometer feeds the network one reading at a time, and only an alert ever leaves the device.
training runs that caught every simulated test fall, with zero false alarms
60 of 60
readings on average between a fall starting and the alert
0.0
parameters in the smallest network, the plain RNN
337
of weights for the largest network, the LSTM
Under 6 KB

Where it's used

Always on, always watching

Fall-detection pendants and smartwatch fall alerts protect older and at-risk people who live alone. The device watches a live accelerometer stream around the clock, on battery power, and has to decide by itself whether what just happened was a real fall worth raising the alarm for.

A fall isn’t one moment. It’s a brief free fall, a sharp impact, and then a person who doesn’t get up normally. Telling that apart from a device dropped on a table means remembering the free fall once the impact arrives, then watching for unusual stillness long after. That’s a job for a network with memory.

  • Fall-detection pendants that raise the alarm on their own
  • Smartwatch fall alerts for people who live alone
  • Private by design: only the alert ever leaves the device

The data

Simulated falls in everyday motion

Every training and test sequence is simulated on the fly, so nothing the network is tested on was ever seen in training. Each one is 150 accelerometer readings of everyday motion, and half of them have a fall spliced in at a random moment.

Everyday motion
gentle, noisy movement, with gravity holding the total near 1 g
Free fall
5 to 8 readings of near weightlessness, the total dropping toward 0 g
Impact
a sharp spike lasting a reading or two
Stillness
the rest of the sequence lying still, turned to a new orientation
Two line charts of x, y and z acceleration and their magnitude over 150 timesteps. Normal activity: magnitude steady near 1 g. Fall: magnitude near 1 g until timestep 115, then near 0 g for several timesteps of free fall, a spike near 4 g at impact, then steady near 1 g with the axes at new constant values. The fall portion is shaded as labeled 1.
One normal sequence and one with a fall. Once the person has landed the total is back at 1 g, so it's the history, the free fall and the new resting angle, that gives the fall away.

How we built it

Three networks, one job

Our library has three kinds of recurrent layer, and we trained each one on the identical task. All three read one accelerometer sample at a time, carry what they’ve seen forward to the next, and give a fall probability at every step.

Plain RNN train_rnn.c

One hidden state, passed through tanh at every step. The simplest of the three, and the fastest to train.

337 parameters

RNN architecture: input of 3 accelerometer axes into a 16-unit tanh RNN layer with a recurrent self-loop carrying hidden state h, into a single sigmoid output for fall probability.

GRU train_gru.c

Reset and update gates decide how much of the hidden state to keep at each step, for about three times the parameters of the RNN.

977 parameters

GRU architecture: input of 3 accelerometer axes into a 16-unit GRU layer with a recurrent self-loop carrying hidden state h, gated by reset and update gates, into a single sigmoid output.

LSTM train_lstm.c

A hidden state plus a separately gated cell state, built to hold on to a signal over long gaps.

1,297 parameters

LSTM architecture: input of 3 accelerometer axes into a 16-unit LSTM layer with two recurrent loops, cell state c gated by forget and input gates, and hidden state h, into a single sigmoid output.

We kept the safest model, not just the lowest-error one. After each round of training we counted missed falls and false alarms on 200 validation sequences and kept the round with the fewest. Choosing on error alone would have kept a false-alarming model in up to 10 of 60 runs. Choosing on mistakes kept none.

Results

Every fall caught, no false alarms

We trained and tested each network 20 times, from a fresh random start each time. All 60 trained models caught all 50 simulated test falls, raised no false alarms on 50 normal sequences, and flagged each fall the moment it began.

NetworkParametersRuns with every fall caught, no false alarmsReading-by-reading accuracyTraining rounds
Plain RNN33720 of 20100.00%34
GRU97720 of 20100.00%99
LSTM1,29720 of 2099.79%41

Accuracy and training rounds are medians over each network’s 20 runs. Every run of every network trained in under 6 seconds on a desktop.

Which one to pick

For this job the plain RNN is enough, and it trains fastest, in a median of 34 rounds. The GRU is the most exact reading by reading, at 100.00% in 18 of 20 runs, but takes the longest to train. The LSTM lands in between. What a wearer would actually notice is a missed fall or a false alarm, and all three were perfect on both.

Dot plots of twenty runs per architecture. Training epochs before early stopping, on a log scale: RNN median 34 with two runs at the 500-epoch cap, GRU median 99, LSTM median 41. Per-timestep test accuracy: RNN and GRU median 100 percent, LSTM median 99.8 percent with a low of 98.7.
Twenty training runs per network, each tested on 100 new sequences. Each dot is one run, and the bar is the median.

On the device

Light enough for a battery-powered pendant

The firmware loop is one call per accelerometer reading. Hand the network the three axes and raise an alert when its output crosses the threshold. The network keeps its own memory between readings, so the firmware stores nothing but the model itself.

Even the largest of the three, the LSTM, is under 6 KB of weights, and each reading costs one small recurrent step. Our tools can also convert a trained model to 8-bit integers and to a format that runs straight out of flash.

parameters, depending on the network
337 to 1,297
of weights for the largest, the LSTM
Under 6 KB
to the network per accelerometer reading
1 call
the one thing that ever leaves the device
Alert only

Ready to build your next intelligent device?

Let's discuss your project and how Cole Design & Development can bring your idea to life.

Founded in 2008 · Hudson, Ohio · info@coledd.com