Motivating Neural Style Transfer
-
Neural style transfer involves combining two images together:
- One image refers to our content image
- The second image refers to our style image
- Combining these two images creates a genereated image
- Essentially, we apply a style from one image to our content image
- Then, the generated image will be include the content of our content image with the style from our style image
Introducing the Cost Function for Neural Style Transfer
- We must define a new cost function in order to build a neural style transfer system
- The cost function measures how well our generated image fits to our data
- The cost function is minimized using gradient descent
- The cost function is defined as the following:
-
The cost function is made up of two cost sub-functions:
- The cost function is the cost of the content image
- The cost function is the cost of the style image
- The content cost function measures the similarity between the content image and generated image
- The style cost function measures the similarity between the style image and generated image
- The hyperaparameters and specify the weighting between the content and style cost functions
- For example, we could increase to place more weight on the content cost function
- We could also decrease to place more weight on the content cost function
Using the Cost Function to Generate Image
-
The general algorithm looks like the following:
- Initiate some random with the following dimensions:
- Use gradient descent to minimize :
- Therefore, gradient descent updates the pixels of our image
- An example looks like the following:
More about the Content Cost Function
tldr
References
Previous