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.

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…
The best portable power stations
EcoFlow DELTA 2 on table at campsite for quick charging.

Affordable and efficient portable power is a necessity these days, keeping our electronic devices operational while on the go. But there are literally dozens of options to choose from, making it abundantly difficult to decide which mobile charging solution is best for you. We've sorted through countless portable power optionsĀ and came up with six of the best portable power stations to keep your smartphones, tablets, laptops, and other gadgets functioning while living off the grid.
The best overall: Jackery Explorer 1000

Jackery has been a mainstay in the portable power market for several years, and today, the company continues to set the standard. With three AC outlets, two USB-A, and two USB-C plugs, you'll have plenty of options for keeping your gadgets charged.

Read more
CES 2023: HD Hyundai’s Avikus is an A.I. for autonomous boat and marine navigation
Demonstration of NeuBoat level 2 autonomous navigation system at the Fort Lauderdale International Boat Show

This content was produced in partnership with HD Hyundai.
Autonomous vehicle navigation technology is certainly nothing new and has been in the works for the better part of a decade at this point. But one of the most common forms we see and hear about is the type used to control steering in road-based vehicles. That's not the only place where technology can make a huge difference. Autonomous driving systems can offer incredible benefits to boats and marine vehicles, too, which is precisely why HD Hyundai has unveiled its Avikus AI technology -- for marine and watercraft vehicles.

More recently, HD Hyundai participated in the Fort Lauderdale International Boat Show, to demo its NeuBoat level 2 autonomous navigation system for recreational boats. The name mashes together the words "neuron" and "boat" and is quite fitting since the Avikus' A.I. navigation tech is a core component of the solution, it will handle self-recognition, real-time decisions, and controls when on the water. Of course, there are a lot of things happening behind the scenes with HD Hyundai's autonomous navigation solution, which we'll dive into below -- HD Hyundai will also be introducing more about the tech at CES 2023.

Read more
This AI cloned my voice using just three minutes of audio
acapela group voice cloning ad

There's a scene in Mission Impossible 3 that you might recall. In it, our hero Ethan Hunt (Tom Cruise) tackles the movie's villain, holds him at gunpoint, and forces him to read a bizarre series of sentences aloud.

"The pleasure of Busby's company is what I most enjoy," he reluctantly reads. "He put a tack on Miss Yancy's chair, and she called him a horrible boy. At the end of the month, he was flinging two kittens across the width of the room ..."

Read more