Project 8 of 14, for Aaesha
Tide Predictor
A tide forecast from a network with a memory: it reads the river gauge an hour at a time, remembers the hours before, guesses the next, and beats the same-as-last-hour forecast. Then a gate on its memory.
Sign up free to open itLog in
Act 7 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- AaeshaThe river path floods at high tide and half the class walks it, which is why we need an hour's warning.
- NeilI trained a network that reads one hour at a time and remembers, and the weights are in the file.
- PaulRemembers what, exactly?
- AaeshaSome of the hours before, and how many is what I want to find out.
In rnn.py, run Neil's recurrent network over the river gauge. load_tides and load_weights are written; readings go in scaled, as (height - MEAN) / SCALE, and guesses come out the same way.
step(x, h, params): one hour. The new hidden state istanh(x * Wx + h @ Wh + b), and the guess at the next reading ish @ Wy + by, as a plain float. Returns(h, guess).run(xs, params): every reading in order, starting from a hidden state of zeros. Returns the hidden states, one row per reading, and the guesses, one per reading, as arrays.forecast(xs, params, hours): run through every reading, then carry on alone, feeding each guess back in as the next reading. Returnshoursguesses as an array, the first being the guess after the last reading.- Run as a program, it reports how far out the network is an hour ahead, against "same as last hour", and forecasts the next six hours in metres.
- In
lstm.py,lstm_step(x, h, c, params): one hour of an LSTM, with a forget gate on its memory.
One hour ahead, over 287 hours: the network is out by 5.8 cm on average "same as last hour" is out by 46.7 cm Next six hours: 4.01 4.27 4.16 3.72 2.99 2.16
What you learn
What's in it
- A network with a memory
- What it remembers
- One step of the tide network
- How Paul would do it
- Fix Caitlin's version
- Running on its own
- An hour ahead
- Blame back through time
- Blame from twenty hours back
- A gate on the memory
- A gate on the memory
- Neil's sluice
- Ship it