Skip to main content

Digital Trends may earn a commission when you buy through links on our site. Why trust us?

A neural network tried to write a 9th Harry Potter book, with hilarious results

portkey games new harry potter label glasses
Do you remember that memorable scene in the Harry Potter books when a person seeking revenge on Ron turns out to be Dumbledore hiding behind a cream cake?

If you don’t, that’s probably because you read the version of Harry Potter written by J.K. Rowling instead of an LSTM recurrent neural network — trained to generate new Hogwarts-related stories using a data set consisting of the series’ first four books.

“I’ve been experimenting with deep learning over the past few weeks, and the Harry Potter story is the result of one of those experiments,” creator Max Deutsch told Digital Trends. “Beyond just looking for a fun way to practice what I’ve been learning, the Harry Potter project was an attempt to make something enjoyable to read.”

Since the results are more surreal mashup than anything likely to give Rowling sleepless nights, “enjoyable” may not be exactly the word. However, it’s a fascinating demonstration of what happens when a neural network turns its attention to creativity.

“The computer is quite good at capturing the rhythm and style of the source text, but the sentences themselves are mostly nonsense,” Deutsch admits. “Occasionally, there is a glimmer of sense, and these moments — plus the knowledge that a computer wrote it — is what makes the read enjoyable to me.”

Interestingly, this isn’t the first time textual analysis algorithms have been applied to the work of J.K. Rowling. When the U.K. newspaper the Sunday Times outed the mega-successful author as the scribe of detective novel The Cuckoo’s Calling a few years ago — writing under the pen name Robert Galbraith — computer scientists were called in to use machine learning to solve the mystery. By analyzing the text based on word-length distribution, usage of common words like “the” and “of,” and recurring-word pairings, they proved that she was.

Max Deutsch’s work might not have quite the academic rigor of that work, but it moves beyond it by not simply analyzing existing works — but generating new ones. “Creativity is a hard thing to explain, even in the context of humans,” he says. “If creativity is simply the act of creating something new — often based on connecting pre-existing things in new ways — then you can argue that the Harry Potter neural network was very creative. In fact, this might be the first time anyone, or anything, has constructed the sentence: ‘Dumbledore will get out from behind a cream cake.’”

You can read the rest of Deutsch’s deep learning Harry Potter story here.

Editors' Recommendations

Luke Dormehl
I'm a UK-based tech writer covering Cool Tech at Digital Trends. I've also written for Fast Company, Wired, the Guardian…
This crazily realistic video forgery of Obama was generated by a lip-syncing AI
ai created fake president obama screen shot 2017 07 14 at 22 11 57

Regardless of which side of the political aisle you sit on, chances are you’ve got some strong opinions on “fake news.” Whether it’s comments taken out of context, or quotes being outright fabricated, fake news is a frustrating byproduct of today’s twenty-first century news cycle.

Well, we’re sorry to tell you that things are about to get much, much worse!

Read more
Neural network can create high-res images based on a text description
ai generates images based on text birdflowerdemo

As far as artificial intelligence goes, 2016 has been the year of deep learning. Brain-inspired neural networks have received massive amounts of investment in time, resources and funding -- and, boy, has it ever paid off!

In a new piece of research -- carried out by investigators at Rutgers University, the University of North Carolina at Charlotte, Lehigh University, and the Chinese University of Hong Kong -- neural networks have been used to generate high quality images based on nothing more detailed than basic text descriptions.

Read more
Make America tweet again! Trump twitterbot is running for president
zillow canada housing trump

Donald Trump’s newest challenger is a twitterbot that was trained by Trump himself. DeepDrumpf, a chatbot trained on Trump’s own words, recently announced its run for president and launched a GoFundMe for campaign donations, all of which will go toward supporting girls in STEM studies.

DeepDrumpf was created in March by Brad Hayes, an MIT Computer Science and Artificial Intelligence Laboratory (CSAIL) postdoc with a penchant for politics and neural networks. Back then, the Republican primaries were in full swing and Trump had established himself as a contender.

Read more