Implementing DeepDream with Keras

David Landup
David Landup

Imports

Let's start with the imports! We'll mainly be working with low-level TensorFlow in this lesson, and it's a great moment to introduce some of the tensor operations that happen under the hood, as well as to introduce TensorFlow Addons - an officially-backed community-driven library that builds on top of TensorFlow to introduce non-standard elements. This is a great time to practice TensorFlow operations, optimizing functions by running them in graph mode, and overall getting used to the low-level API of TensorFlow, which contrary to (oudated) public sentiment, isn't that messy or non-Pythonic.

Note: Spoiler alert - TensorFlow tensor operations are similar to NumPy array operations. So much so, that they're arguably almost identical, and confidence with the NumPy API translated into confidence with the TensorFlow API.

Let's import the libraries we'll be using:

import tensorflow as tf
import tensorflow_probability as tfp
import tensorflow_addons as tfa

import numpy as np
import matplotlib.pyplot as plt

import urllib
import cv2

As usual, let's set up a config dictionary that'll hold some of the global variables we'll be using and to make testing a bit easier and more readable:

config = {
    'LR': 0.01,
    'PYRAMID_SIZE': 1.4,
    'DEFAULT_STEPS': 1000,
    'PYRAMID_STEPS': 200,
    'DPI': 300
}
Start project to continue
Lessson 1/2
You must first start the project before tracking progress.
Mark completed

© 2013-2024 Stack Abuse. All rights reserved.

AboutDisclosurePrivacyTerms