Artificial intelligence is getting so good it's scary. Some of the brightest human minds, from Stephen Hawking to Elon Musk, are worried about what the singularity might mean for our species. What will happen when computers can outsmart people?

But just when it seems like the end might be near, puppyslug and pig-snail come along to reassure us — or at least frighten us in a different way.

These creatures are among the many stars of Google's new DeepDream tool, which uses the neural network behind Google Images to hilariously overanalyze photos. The results may offer comforting evidence that we're still smarter than computers, but they also offer psychedelic artwork to rival the surrealism of Salvador Dali.

An artificial neural network is like a simplified brain, trained by humans to perform tasks on its own. Google trains neural networks to interpret images, showing them millions of examples and gradually adjusting them until they classify images correctly.

"The network typically consists of 10-30 stacked layers of artificial neurons," Google software engineers Alexander Mordvintsev, Mike Tyka and intern Christopher Olah write in a blog post. "Each image is fed into the input layer, which then talks to the next layer, until eventually the 'output' layer is reached. The network's 'answer' comes from this final output layer."

But these neural networks don't just assess existing photos — they can also be prompted to generate images based on their memories of photo training. Engineers can coax the network to embellish or even create pictures from its own psyche, sort of like the way our brains conjure up dreams from earlier experiences.

cloud shapesLike humans, Google's image-analyzing neural networks have a tendency to see objects in clouds. (Photo: Google)

"We ask the network: 'Whatever you see there, I want more of it!'" the Google engineers write. "This creates a feedback loop: If a cloud looks a little bit like a bird, the network will make it look more like a bird. This in turn will make the network recognize the bird even more strongly on the next pass and so forth, until a highly detailed bird appears, seemingly out of nowhere."

This is eerily similar to a natural phenomenon in humans known as pareidolia. Because evolution has wired our brains to recognize other human faces, we almost can't prevent ourselves from seeing "faces" in everything from electrical outlets to rocky hillsides. And now we've recreated this tendency in computers — sort of.

This Google network was trained mostly on images of animals, so it has a natural bias to see dogs, birds and fish everywhere. But since the data are stored in its memory at such high levels of abstraction, the results are "an interesting remix of these learned features," Google explains. And that's how we get trippy mashups like these:

animal mashups

The nebulous shapes of clouds lend themselves to this kind of Rorschach test, but the technique works on any image. Certain features spur certain interpretations — horizons tend to get populated with towers and pagodas, Google notes, while rocks and trees often morph into buildings. But regardless of the original subject matter, the network is never satisfied that anything is as simple as it first appears. It's like "Yeah, but what's this MADE of? Dogs? It's made of dogs, isn't it?"

Puppyslug NebulaThe "Puppyslug Neblua," courtesy of NASA and Google DeepDream. (Photo: Devine Lu Linvega/NASA)

NSA headquarters in DeepDreamThe headquarters of the U.S. National Security Agency is apparently made of cars. (Photo: Samim/NSA)

This technique — dubbed "inceptionism" by Google — can even be applied to a random-noise image, so the result is entirely the work of the neural network, like an illustration created from scratch. Here's one "dream" produced by a network that had been trained on images of places:

Google DeepDream placesA neural network trained on places dreamed up this horizon-free world of pagodas and fountains. (Photo: Google)

There may be some practical value to all this, since it sheds light on the way neural networks work and can help engineers improve them. "It also makes us wonder whether neural networks could become a tool for artists," Google adds, "or perhaps even shed a little light on the roots of the creative process in general."

And speaking of the creative process, Google has released the code for DeepDream, letting anyone experiment with it. The code needs to be hosted on a website, but several are already doing so (and being overwhelmed by Web traffic, of course). Try Psychic VR Lab and Deep Neural Net Dreams, if you can get through.

You can also browse through the growing canon of "inceptionized" images via the #deepdream hashtag on Twitter and Google Plus. The technique is even being applied to video clips, perhaps none more fittingly than this scene from the already-trippy 1998 film "Fear and Loathing in Las Vegas."

Sweet dreams.

Related on MNN:

Russell McLendon ( @russmclendon ) writes about humans and other wildlife.

Behold the surreal imagery of Google's 'dreams'
The search giant has trained neural networks to interpret photos, but they can also be coaxed to create monsters.