I am making a recurrent neural network from scratch in python using numpy, trained on Shakespeare text to generate character-by-character in his style.This is an improvement on the previous neural network that I made as it keeps a memory based on the things it has recently seen, so it’s next prediction depends on what it has previously seen which will hopefully make it be able to learn more advanced patterns.I added loading and chunking of data, so basically it takes in a text file, and then it splits it into chunks (I use 25 character long chunks) in pairs with one shifted across by one and saves it as input and targets.I wrote the forward pass, loops through each character in a chunk, updates a hidden state with tanh, then a softmax over the vocab to predict the next character.I implemented backprop through time, which was definitely the hardest part, had a few off-by-one bugs in the hidden state indexing that took a while to track down.I did a numerical gradient check to double-check the backward pass against finite differences before training it, and realised I forgot to update the bias gradient so it wasn’t training properly.I used adagrad as the matrix updater from the gradients which works by updating the gradients by a smaller and smaller amount each time (I looked it up and apparently it is a good way to do it).I wrote the output function where I give it an input function, and then the model predicts the next character, and then it feeds the output back into the model and repeats for as many characters as I want.I then trained it on Shakespeare text and ran 100k iterations at hidden size 100, took about 2 mins and started outputting vaguely word-shaped gibberish with correct capitalisation and character-name formatting.I then increased the hidden size from 100 to 256 and trained it more, and it still looks like gibberish but improved a bit, some of the output is what you can see in the screenshot.