DeepDream (2015): When a Network Hallucinated Dogs Everywhere

Google asked a trained image classifier to enhance whatever it saw, and the internet got its first psychedelic neural-network filter

Contents

On 18 June 2015 a Google Research blog post titled “Inceptionism: Going Deeper into Neural Networks” showed a set of pictures that looked like the aftermath of a very strange dream. Clouds had grown animal faces. A horizon line sprouted towers and pagodas. Trees had turned into buildings. Two weeks later Google released the code, and within days the internet was dreaming too.

The technique became known as DeepDream. It was the first time a large audience saw what happens inside an image-recognition network, and it did so by accident, as a debugging tool that turned out to be beautiful and unsettling in equal measure. The piece below is written from the published record: the two Google Research posts and the coverage around them. DeepDream is a 2015 Caffe-era notebook, and this post is written from Google’s published record.

The people and the dates

The authors of both Google posts are Alexander Mordvintsev, Christopher Olah and Mike Tyka, all Google researchers at the time. The June post, “Inceptionism”, introduced the idea and a gallery of image pairs. The follow-up on 1 July 2015, “DeepDream: a code example for visualizing neural networks”, open-sourced the tool as an IPython notebook on GitHub. It relied on the Caffe deep-learning framework plus NumPy, SciPy and PIL, so anyone with a Python setup could try it on their own photographs.

The name “Inceptionism” is a pun. The network behind the images was GoogLeNet, a deep convolutional network of the Inception family that had won the 2014 ImageNet recognition challenge, and the family was named after the film Inception, in which dreams nest inside dreams. The Wikipedia article on DeepDream records that the program was developed in 2014 for that challenge and released in July 2015, and reports over 10,000 Twitter posts using the #deepdream hashtag between 1 and 6 July.

A photograph of a school courtyard whose walls and tree are covered in swirling eye-like and animal-like textures from a DeepDream filter.
A DeepDream-processed photograph: every edge and texture is exaggerated into the swirls and eye shapes the network was tuned to find. Photo: SchillerGym Hof DeepDream 20220213 by Fotovorlage: PantheraLeo1359531 😺 (talk) Software: Aleksa Gordic (https://github, Public domain, via Wikimedia Commons.

Why a classifier can draw

To see why DeepDream works you need one fact about image classifiers: they are built in layers, and each layer looks for something more elaborate than the one before. The AlexNet and ImageNet post describes the moment this approach won, and ResNet shows how deep the stacks went by 2015. The Google authors summarise the hierarchy in their first post: lower layers pick out basic features like edges and corners, middle layers respond to textures and parts such as a door or a leaf, and the top layers assemble those into whole objects.

A classifier trained on ImageNet learns this for a thousand categories, and a large share of those categories are animals. Well over a hundred of the thousand are dog breeds. That detail is the entire joke of the technique, and it explains the title of this post.

The Google researchers noticed that a network trained to tell things apart “has quite a bit of the information needed to generate images too.” Training only ever pushed the network in one direction, from picture to label. Nothing stops you running the process the other way and asking which pictures would make a particular neuron fire hardest. This is the same intuition behind generative adversarial networks, though DeepDream needs no second network and no new training at all.

How the dreaming works

The Inceptionism post puts the method as a request made of the network: “Whatever you see there, I want more of it!” The procedure runs as a loop:

  1. Take an image, either a photograph or random noise.
  2. Pass it through the network up to a chosen layer.
  3. Measure how strongly that layer responds to whatever it finds.
  4. Use backpropagation to work out how each pixel should change to make that response stronger.
  5. Nudge the pixels in that direction, which is gradient ascent on the image, and repeat.
PhotoChosen layerMore of thatNew pixelsRepeat: each pass amplifies what the layer already half-sees
The DeepDream loop. The network’s weights never change; only the picture does.

The point to hold on to is that the weights stay frozen. Ordinary training uses backpropagation to change the network so it fits the data. DeepDream uses the same calculation to change the picture so it fits the network. That reversal is why Google called it “turning the network upside down”.

Because the loop amplifies whatever the layer already half-detects, the result depends heavily on the starting image and the layer. A cloud has vaguely animal-like contours, so a layer tuned to dog faces finds a faint dog in it and strengthens that hint, which makes the next pass see the dog more clearly, until the cloud has eyes and a snout. The effect is a runaway feedback loop of pareidolia, the same instinct that makes people see faces in a wall socket.

The released tool exposed the knobs that mattered. Per the July post, a user could “supply an image and choose which layers in the network to enhance, how many iterations to apply and how far to zoom in.” Choosing a low layer gave swirling brushstroke textures and edges. Choosing a high layer gave whole creatures. Zooming in a little after each pass and feeding the output back as input produced the endless-descent video animations in the Google gallery. The network could also start from random noise and invent a scene with no photograph to guide it, which the Inceptionism post describes as the network’s “dreams”.

The craft: layers, scales and the dog problem

Three choices shape every DeepDream image, and they explain why two people running the same photograph get different results.

The first is the layer. Early layers respond to edges and simple textures, so enhancing them gives a hatching or brushstroke effect that looks like an engraving. Mid-level layers respond to repeated parts such as scales, feathers, eyes and windows, which produces the busy fractal-bird look the technique is famous for. The deepest layers carry whole-object detectors, and that is where the dogs live, since the top of an ImageNet classifier is organised around its thousand labels.

The second is scale. The published notebook does not enhance the image at one resolution. It works on the picture at several sizes, starting small and feeding the result up to the next size. Patterns produced at the coarse scale become the large forms and patterns at the fine scale become their texture, which is why the images show eyes inside eyes.

The third is the stopping point. Every pass pushes the same direction, so the image drifts further from the original. A handful of iterations reads as a stylised photograph and dozens read as a hallucination. The Google gallery shows the whole range.

The dog bias deserves a plain statement. The network dreams in the things it was trained to name, and ImageNet’s label list is lopsided toward animals, with dogs dominating. A network trained on a different dataset, such as scenes or places, produces buildings, landscapes and architecture instead; the Google authors note that different training sets change what the dreams contain. The model’s output is a readout of its training data.

What it was supposed to be for

DeepDream is best remembered as art, but the Google authors framed it as a research tool. In the 2015 post the team writes that the neural networks of the day were treated as black boxes, and that visualisation could show what each layer had really learned.

Their clearest example is the dumbbell. When they asked a network to produce a dumbbell from noise, the pictures included muscular arms holding the weights, because in the training photographs dumbbells almost always appeared in someone’s hands. The network had learned “dumbbell” and “arm” as a single concept. The researchers took this as a diagnostic: visualisation can expose what a network has learned about a category, including the parts it should never have absorbed. That is a pointed early example of a problem that returns whenever a model learns the context of a thing instead of the thing itself, and it connects to the contamination and shortcut problems discussed in the benchmarks post.

The same technique also gave interpretability research a template. Visualising what individual neurons or layers respond to became a standard way to inspect vision networks, the starting point for a line of work that continues in language models today.

The cultural moment

The code release at the start of July turned a lab curiosity into a mass phenomenon. Know Your Meme records that the hashtag spread rapidly, and the images had a distinctive look: saturated colour, fractal repetition, eyes and dog snouts emerging from every texture. It resembled a psychedelic poster, and the comparison to hallucination was impossible to avoid, which is partly why it spread.

Part of the appeal was access. For the first time a member of the public could take their own photograph, run it through a state-of-the-art vision network and see something of how the machine saw. Mordvintsev later became an exhibited digital artist, and his DeepDream-era works are sold through galleries. The look also left a footprint on later image tools. StyleGAN produced photorealistic faces three years later, and CLIP in 2021 gave artists a new way to steer a network toward a description. Those tools generated pictures from scratch. DeepDream could only exaggerate what was already in an image.

Where it sits in the line to today’s image models

DeepDream is a dead end as a generator and a useful signpost as an idea. It established three things that carried forward.

First, a network trained for recognition holds a usable model of what things look like. Second, you can steer a picture by following the gradient of a network’s response, which is the same principle that later guided-generation systems rely on. Third, the public will happily play with a tool that shows them a machine’s inner world, which every image-generation product since has quietly relied on.

Modern image generators work differently. The diffusion explainer shows a model trained from the beginning to remove noise from images, step by step, producing coherent pictures rather than amplified hallucinations. Latent diffusion then made that process cheap enough to run at home. The Stable Diffusion family, which I have run on both an NVIDIA GPU box and an Apple Silicon Mac, descends from the same fascination with letting a network make pictures, though through a completely different mechanism.

Is it worth remembering?

Yes, for two reasons. The technical idea, optimising an input to excite a network, remains alive in interpretability work. The human lesson is that opening up a model, even by accident, can produce a picture of its priors: a network that saw a thousand categories and over a hundred dog breeds dreams in dogs. The next time an image model fills a background with oddly consistent detail, DeepDream is the ancestor that explains why the model’s training set shows through.

Sources: Inceptionism: Going Deeper into Neural Networks (Google Research, June 2015) · DeepDream: a code example for visualizing neural networks (Google Research, July 2015) · DeepDream on Wikipedia · Google DeepDream on Know Your Meme

Smarc
Written by Smarc

Founder and editor of Aside House. A lifelong tinkerer who self-hosts far more than is sensible, hardens Linux boxes for fun, and prods the latest AI tools to see what they can really do. The how-to guides here are the notes Smarc wishes had existed the first time round.

Smarc is the editor of Aside House. The homelab, the hardware and the opinions are real; the guides are drafted with AI assistance. Infrastructure details are genericised on purpose.