1. 程式人生 > >50行程式碼實現對抗生成網路GAN

50行程式碼實現對抗生成網路GAN

轉自大牛Dev NagDev Nag是前谷歌高階工程師、AI 初創公司 Wavefront 創始人兼 CTO,本文介紹了他是如何用不到五十行程式碼,在 PyTorch 平臺上完成對 GAN 的訓練。

In 2014, Ian Goodfellow and his colleagues at the University of Montreal published a stunning paper introducing the world to GANs, or generative adversarial networks. Through an innovative combination of computational graphs and game theory they showed that, given enough modeling power, two models fighting against each other would be able to co-train through plain old backpropagation.

The models play two distinct (literally, adversarial) roles. Given some real data set RG is the generator, trying to create fake data that looks just like the genuine data, while D is the discriminator, getting data from either the real set or and labeling the difference. Goodfellow’s metaphor (and a fine one it is) was that G

 was like a team of forgers trying to match real paintings with their output, while D was the team of detectives trying to tell the difference. (Except that in this case, the forgers G never get to see the original data — only the judgments of D. They’re like blind forgers.)

In the ideal case, both D

 and G would get better over time until G had essentially become a “master forger” of the genuine article and D was at a loss, “unable to differentiate between the two distributions.”

In practice, what Goodfellow had shown was that G would be able to perform a form of unsupervised learning on the original dataset, finding some way of representing that data in a (possibly) much lower-dimensional manner. And as Yann LeCun famously stated, unsupervised learning is the “cake” of true AI.