pdfcoffee
GenerativeAdversarial NetworksIn this chapter we will discuss Generative Adversarial Networks (GANs) andits variants. GANs have been defined as the most interesting idea in the last 10 yearsin ML (https://www.quora.com/What-are-some-recent-and-potentiallyupcoming-breakthroughs-in-deep-learning)by Yann LeCun, one of the fathersof deep learning. GANs are able to learn how to reproduce synthetic data that looksreal. For instance, computers can learn how to paint and create realistic images.The idea was originally proposed by Ian Goodfellow (for more information refer toNIPS 2016 Tutorial: Generative Adversarial Networks, by I. Goodfellow, 2016); he hasworked with the University of Montreal, Google Brain, and OpenAI, and is presentlyworking in Apple Inc as the Director of Machine Learning.In this chapter we will cover different types of GANs and see some of theirimplementation in TensorFlow 2.0. Broadly we will cover the following topics:• What is a GAN?• Deep convolutional GANs• SRGAN• CycleGAN• Applications of GANsWhat is a GAN?The ability of GANs to learn high-dimensional, complex data distributions havemade them very popular with researchers in recent years. Between 2016, whenthey were first proposed by Ian Goodfellow, up to 2019, we have more than 40,000research papers related to GANs. This is in the space of just three years![ 191 ]
Generative Adversarial NetworksThe applications of GANs include creating images, videos, music, and even naturallanguages. They have been employed in tasks like image-to-image translation, imagesuper resolution, drug discovery, and even next-frame prediction in video.The key idea of GAN can be easily understood by considering it analogous to "artforgery," which is the process of creating works of art that are falsely credited toother usually more famous artists. GANs train two neural nets simultaneously. Thegenerator G(Z) is the one that makes the forgery, and the discriminator D(Y) is theone that can judge how realistic the reproductions are, based on its observations ofauthentic pieces of art and copies. D(Y) takes an input Y (for instance, an image), andexpresses a vote to judge how real the input is. In general, a value close to 1 denotes"real," while a value close to 0 denotes "forgery." G(Z) takes an input from randomnoise Z and it trains itself to fool D into thinking that whatever G(Z) produces is real.The goal of training the discriminator D(Y) is to maximize D(Y) for every imagefrom the true data distribution, and to minimize D(Y) for every image not fromthe true data distribution. So, G and D play opposite games: hence the nameadversarial training. Note that we train G and D in an alternating manner, whereeach one of their objectives is expressed as a loss function optimized via a gradientdescent. The generative model continues to improve its forgery capabilities, andthe discriminative model continues to improve its forgery recognition capabilities.The discriminator network (usually a standard convolutional neural network)tries to classify if an input image is real or generated. The important new idea isto backpropagate through both the discriminator and the generator to adjust thegenerator's parameters in such a way that the generator can learn how to fool thediscriminator more often. At the end the generator will learn how to produce imagesthat are indistinguishable from the real ones:Of course, GANs involve working towards an equilibrium in a game involving twoplayers. Let us first understand what we mean by equilibrium here. When we start,one of the two players are hopefully better than the other. This pushes the other toimprove and this way both generator and discriminator push each other towardsimprovement.[ 192 ]
- Page 175 and 176: Advanced Convolutional Neural Netwo
- Page 177 and 178: Advanced Convolutional Neural Netwo
- Page 179 and 180: Advanced Convolutional Neural Netwo
- Page 181 and 182: Advanced Convolutional Neural Netwo
- Page 183 and 184: Advanced Convolutional Neural Netwo
- Page 185 and 186: Advanced Convolutional Neural Netwo
- Page 187 and 188: Advanced Convolutional Neural Netwo
- Page 189 and 190: Advanced Convolutional Neural Netwo
- Page 191 and 192: Advanced Convolutional Neural Netwo
- Page 193 and 194: Advanced Convolutional Neural Netwo
- Page 195 and 196: Advanced Convolutional Neural Netwo
- Page 197 and 198: Advanced Convolutional Neural Netwo
- Page 199 and 200: Advanced Convolutional Neural Netwo
- Page 201 and 202: Advanced Convolutional Neural Netwo
- Page 203 and 204: Advanced Convolutional Neural Netwo
- Page 205 and 206: Advanced Convolutional Neural Netwo
- Page 207 and 208: Advanced Convolutional Neural Netwo
- Page 209 and 210: Advanced Convolutional Neural Netwo
- Page 211 and 212: Advanced Convolutional Neural Netwo
- Page 213 and 214: Advanced Convolutional Neural Netwo
- Page 215 and 216: Advanced Convolutional Neural Netwo
- Page 217 and 218: Advanced Convolutional Neural Netwo
- Page 219 and 220: Advanced Convolutional Neural Netwo
- Page 221 and 222: Advanced Convolutional Neural Netwo
- Page 223 and 224: Advanced Convolutional Neural Netwo
- Page 228 and 229: [ 193 ]Chapter 6Eventually, we reac
- Page 230 and 231: [ 195 ]Chapter 6Next, we combine th
- Page 232 and 233: Chapter 6And handwritten digits gen
- Page 234 and 235: Chapter 6Figure 1: Visualizing the
- Page 236 and 237: Chapter 6The resultant generator mo
- Page 238 and 239: Chapter 6Figure 4: A summary of res
- Page 240 and 241: Chapter 6def train(self, epochs, ba
- Page 242 and 243: Chapter 6The preceding images were
- Page 244 and 245: Chapter 6Another interesting paper
- Page 246 and 247: Chapter 6To elaborate, let us say t
- Page 248 and 249: Chapter 6Figure 7: The architecture
- Page 250 and 251: Chapter 6Figure 11: Illegible initi
- Page 252 and 253: Chapter 6Bedrooms: Generated bedroo
- Page 254 and 255: Chapter 6The images need to be norm
- Page 256 and 257: Chapter 6initializer = tf.random_no
- Page 258 and 259: Cool, right? Now we can define the
- Page 260 and 261: Chapter 6d_loss = (dA_loss + dB_los
- Page 262 and 263: Chapter 6generator_AB.save_weights(
- Page 264: 6. Ledig, Christian, et al. Photo-R
- Page 267 and 268: Word EmbeddingsDeep learning models
- Page 269 and 270: Word EmbeddingsFor example, "crucia
- Page 271 and 272: Word EmbeddingsAssuming a window si
- Page 273 and 274: Word EmbeddingsGloVeThe Global vect
Generative Adversarial Networks
The applications of GANs include creating images, videos, music, and even natural
languages. They have been employed in tasks like image-to-image translation, image
super resolution, drug discovery, and even next-frame prediction in video.
The key idea of GAN can be easily understood by considering it analogous to "art
forgery," which is the process of creating works of art that are falsely credited to
other usually more famous artists. GANs train two neural nets simultaneously. The
generator G(Z) is the one that makes the forgery, and the discriminator D(Y) is the
one that can judge how realistic the reproductions are, based on its observations of
authentic pieces of art and copies. D(Y) takes an input Y (for instance, an image), and
expresses a vote to judge how real the input is. In general, a value close to 1 denotes
"real," while a value close to 0 denotes "forgery." G(Z) takes an input from random
noise Z and it trains itself to fool D into thinking that whatever G(Z) produces is real.
The goal of training the discriminator D(Y) is to maximize D(Y) for every image
from the true data distribution, and to minimize D(Y) for every image not from
the true data distribution. So, G and D play opposite games: hence the name
adversarial training. Note that we train G and D in an alternating manner, where
each one of their objectives is expressed as a loss function optimized via a gradient
descent. The generative model continues to improve its forgery capabilities, and
the discriminative model continues to improve its forgery recognition capabilities.
The discriminator network (usually a standard convolutional neural network)
tries to classify if an input image is real or generated. The important new idea is
to backpropagate through both the discriminator and the generator to adjust the
generator's parameters in such a way that the generator can learn how to fool the
discriminator more often. At the end the generator will learn how to produce images
that are indistinguishable from the real ones:
Of course, GANs involve working towards an equilibrium in a game involving two
players. Let us first understand what we mean by equilibrium here. When we start,
one of the two players are hopefully better than the other. This pushes the other to
improve and this way both generator and discriminator push each other towards
improvement.
[ 192 ]