DEV Community

LSTM Learns To Write Shakespeare Fanfiction

n8programs on September 23, 2020

Recently, I used node.js and tensorflow.js to train an LSTM (Long Short Term Memory Network) on the life works of Shakespeare. I documented it in a...
Collapse
 
shadowtime2000 profile image
shadowtime2000

I have always tried to implement something like this in javascript because I don't like python syntax much but I have never been able to do so. Are you thinking of posting the source code on Github?

Collapse
 
n8python profile image
n8programs

Yes, the source code is here: gist.github.com/N8python/93139a670...

Collapse
 
marcellothearcane profile image
marcellothearcane • Edited

Want some fun? Train it off Finnegan's Wake.

Collapse
 
n8python profile image
n8programs

This is the initial result with 10 characters of memory... more training is needed:

XI 
be she be dear to the 
could that won't 
he have a cories dound the fall for the tome to your deepon and he proyn 
will the prands and sire to the heal for the bear 
to the prast what's parturus of her and free of carce 
shall 
the 
deal purked be the but a tather me ower be the dear and for the 
starled my merread of his stope when I sen all to tatter her never conned and most the 
bellasting porksing him to the mound to the lave a 
frean the grand. What he cranta and a beerny under the 
his 
man the ever off the mubball to be the pras the cracker of his 
prinish with his 
be or the mean and say your ranish pare of the 
fing for you conder he's death 
to the 
love, be the bimbrean, my yulling be and redand and me handrear under your 
went the man he swall your nistent and the light of his litter be on the 
ceam with the burky 
sintreath 
of the gracked the 
ton the contapion, your 
the for the ball of the clan I will here's a time, 
he's dade of sullare and 
and dean of his love a
Enter fullscreen mode Exit fullscreen mode
Collapse
 
marcellothearcane profile image
marcellothearcane

It's perfect.

Thread Thread
 
n8python profile image
n8programs • Edited

It does a bit better with 50 characters of memory:

Vara world Mestiel up 
the time a 
streem of the endab 
with the heard as he shin like the played his strike into the 
porter like Borner Dolly denties, the Green and his persicing the some of the 
slippy of a salt of the 
and beact and could his plister with a triphifing from the was and under his tone the whom the same a wells he had 
turned by a luck of his hick, the evergest best she person, in your sumplished by a farm 
and returning 
the potter which he was to the heads to the persowal prince of his 
such a 
merting his 
the persing the recembers to his bull you as the park the strike me he was the with the 

not a plushed least when the suntines 
of all the recondating the the his 
was a hused and the reding the but where, had the preating about the denice of his conninned who so a 
mill the back at the brown the like the same ded the mindly for the sheeling, in the pinklers and been the courtel 
and the return the sensed of the fight of the warves the cork of his were which he 

Here's a github repo of all the Finnigan's Wake stuff it generated:
github.com/N8python/finnigansWakeGen

Collapse
 
n8python profile image
n8programs

I just looked at Finnegan's Wake... it is even less comprehensible than Shakespeare. I probably will.

Collapse
 
andrewmplummer profile image
Andrew Plummer

I'm beginning to get very interested in NLP haha

Collapse
 
n8python profile image
n8programs

Text generating models are very fun! I'd totally recommend you get into them!

Collapse
 
kretaceous profile image
Abhijit Hota

This is awesome!

Collapse
 
n8python profile image
n8programs

Thanks!