Minimizing the cost function

Our first step will be to generate a noisy random image (G) that looks a bit like the content image (C). The following example on the right is maybe 80% noisy random and it looks 20% like the content image:

Also, we can generate a pure noisy image, and it will work just fine, but it speeds up a bit if we start with a more content-like image. Then, we will use gradient descent (J(G)) exactly as we saw in the first section, and use the following formula:

We will use the feedback, which is the derivation of the cost function, to update the weights. Now, instead of updating the weights, we will additionally update the image's pixels. Here, the G is referring to the pixels of the generated image. And iteration by iteration, the generated image will change to look more like the content and the style image, because the cost function actually measures the difference between the content and generated image, and the style and the generated image. So maybe after 10 iterations the image will appears as follows:

After 100 iterations, it will appear as follows:

And after 200 iterations, it will appear as follows:

After 500, we see that the image generated from a noisy image looks more similar to the content and the style image at the same time, which is shown as follows:

This is happening because we use the feedback of two cost functions—one that measures the difference between the generated image and the content, and the second one that measures the difference between the generated image and the style one. The feedback that we receive is used to update the pixels of that generated image so that it comes closer to the cost function, and indirectly, closer to these images. Cost and style functions are absolutely essential for the quality of generated images, since they are the only feedback we used to update pixels iteration by iteration. In the next section, we will use the knowledge acquired in the previous section about what the layers were learning, to build up those functions. More specifically, we will start with a content cost function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.15.161