Paul's Python CoursePPC

Project 14 of 14, for Aaesha

Notebook Reader

The Act VII capstone, a deep learning project from start to finish: a small network learns Paul's notes four characters at a time, beats the bigram on notes it never saw, and finishes a note when you start one. It learns how he sounds, not what he means. With a write-up.

About 10 hours, in 10 steps.

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

  • AaeshaI've got every comment Paul's left on our code and the notes from his notebook margins, eighty-five of them, one a line.
  • AaeshaI'd like a machine that reads them and finishes a note when you start one, in his voice.
  • PaulAnd when it finishes one I never wrote?
  • AaeshaThen we'll know how well it learnt you, or at least how you sound, if not what you mean.

The Notebook Reader, in four files, built in this order. Each starter is almost empty: a docstring listing what to write.

  1. notes.py: load the 85 notes, hold every fifth back, build the vocabulary (with the newline), and cut the notes into windows: the ids of the characters before each character, padded with newlines, and its own id.
  2. baseline.py: perplexity, and the bigram, counted from the last character of each window. The scores to beat.
  3. model.py: a network that looks up the embeddings of four characters, lays them in a row, and guesses the fifth through a tanh layer and softmax. Forward, backward, and training on mini-batches. Run as a program, it trains and saves my_weights.json.
  4. reader.py: complete(start, params, vocab, rng, temperature=1.0, limit=200) finishes a note, with the same note every time for the same seed. Run as a program, it reads with your weights if you've trained them, and Aaesha's if not.
  5. A write-up and a test plan, through Paul's checklist.
What it prints
Reading with Aaesha's weights.
Good names one a you came test poen thing, the code that are in the code. P.
The duck. P.
Whoever reads this nrom the son. P.

What's in it

  1. Mark it out first
  2. A window of characters before
  3. The notes, as numbers
  4. The scores to beat
  5. Four characters in
  6. The network
  7. The notebook reader
  8. Milestone: the write-up
  9. Ship it