deepdream you start not from blankslightly noisy inputbut rather from an existing image--thus the resulting effects latch on to preexisting visual patternsdistorting elements of the image in somewhat artistic fashion the input images are processed at different scales (called octaves)which improves the quality of the visualizations let' make some deepdreams implementing deepdream in keras you'll start from convnet pretrained on imagenet in kerasmany such convnets are availablevgg vgg xceptionresnet and so on you can implement deepdream with any of thembut your convnet of choice will naturally affect your visualizationsbecause different convnet architectures result in different learned features the convnet used in the original deepdream release was an inception modeland in practice inception is known to produce nice-looking deepdreamsso you'll use the inception model that comes with keras listing loading he pret rained incept ion model from keras applications import inception_v from keras import backend as set_learning_phase( you won' be training the modelso this command disables all trainingspecific operations model inception_v inceptionv (weights='imagenet'include_top=falsebuilds the inception networkwithout its convolutional base the model will be loaded with pretrained imagenet weights nextyou'll compute the lossthe quantity you'll seek to maximize during the gradient-ascent process in for filter visualizationyou tried to maximize the value of specific filter in specific layer hereyou'll simultaneously maximize the activation of all filters in number of layers specificallyyou'll maximize weighted sum of the norm of the activations of set of high-level layers the exact set of layers you choose (as well as their contribution to the final losshas major influence on the visuals you'll be able to produceso you want to make these parameters easily configurable lower layers result in geometric patternswhereas higher layers result in visuals in which you can recognize some classes from imagenet (for examplebirds or dogsyou'll start from somewhat arbitrary configuration involving four layers--but you'll definitely want to explore many different configurations later listing set ing up he deepdream configurat ion layer_contributions 'mixed ' 'mixed ' 'mixed ' 'mixed ' dictionary mapping layer names to coefficient quantifying how much the layer' activation contributes to the loss you'll seek to maximize note that the layer names are hardcoded in the built-in inception application you can list all layer names using model summary(licensed to