Where Google explored artificially intelligent reveries, MIT researchers are now wondering, just in time for Halloween, whether an algorithm could generate night terrors. The artificial intelligence is called the Nightmare Machine. And true to its name, it’s creepy.

Google, like its “don’t be evil” former motto, did not aim for horror show. Under Deep Dream’s influence, photographs of trees were reworked into church steeples. The network reinterpreted leaves as birds. Faces and almost everything else became rainbow dogs, as though Timothy Leary awoke from the dead and shambled into the Westminster show.

Because Google raised the program on a steady diet of animal photographs, the neural network was inclined to see canines, birds and walleyed fish where there were none. The patterns it produced were psychedelic and could be disturbing, though the cute critters curbed the eeriness of the computer’s hallucinations.

There are no multihued puppies to redeem the hellscapes produced by the Nightmare Machine. That’s because the algorithm was trained for one purpose — horror.

This new artificial intelligence infuses images with tendrils, as though inky veins or creeping roots had taken over the world’s landmarks. The Nightmare Machine blackens skies. Human faces warp and turn blood red. A shot of the second presidential debate is remixed into Trump and Clinton standing on a dais of skeletons.

The Nightmare Machine is one of the few, if not the first, “deep-learning” systems designed to evoke fear. The sinister features it produces are the result of what MIT Media Lab researcher Pinar Yanardag Delul called a “nightmarifying” process, she said in an email. Where Google primed Deep Dream to see animals, MIT’s training course for the Nighmare Machine was more ominous.

AD

AD

“We use state-of-the-art deep learning algorithms to learn what haunted houses, ghost towns or toxic cities look like,” Yanardag Delul said. The algorithm extracts elements — such as a bruised-black palette — from these scary templates and implants them in the landmarks.

The MIT scientists argued the Nightmare Machine represented more than an exercise in making bizarre photographs.

“Our research group’s main goal is to understand the barriers between human and machine cooperation,” MIT’s Iyad Rahwan said in an email. “Over the past two years, we’ve seen a rising number of intellectuals and luminaries raising alarms about the potential threat of superintelligent AI on humanity. Pioneer and inventor Elon Musk famously said that as we develop AI, we are ‘summoning the demon.’”

AD

Even in the abstract, in other words, artificial intelligence can be scary. But Yanardag Delul and her colleagues, including Rahwan, wanted to know whether AI could creatively and purposefully unsettle humans.

AD

“Scholars have long commented on the phenomenon of the uncanny valley, which describes how people feel a sense of eeriness and revulsion at robots that appear almost, but not exactly, like real human beings,” Yanardag Delul said. “But can AI elicit more powerful visceral reactions more akin to what we see in a horror movie?”

On the Nightmare Machine website, voters can rate images to teach the artificial intelligence to make faces even scarier. The MIT computer scientists recently analyzed the responses from 100,000 voters to discern which were the scariest.

AD

As far as the Nightmare Machine’s early success, results appear to be mixed. “Initial tallies reveal that humans quickly converge on finding some of them very scary,” MIT research scientist Manuel Cebrian wrote to The Post, “and others not at all.”

AD

You can decide for yourself. The top eight scary faces generated by the Nightmare Machine can be seen below. For those of us who admit that demonic facial expressions are unsettling — scroll down carefully.

Or, as Yanardag Delul said, “Trigger warning goes here.”

You can check out more of the AI’s creepy photos on the Nightmare Machine Instagram account.