2025-Q1-AI 18. GAN, DCGAN, WGAN

 

18.1. Materials / Video (🔴10. jūnijs 18:00, Trešdiena, Riga, Zunda krastmala 10, 122)

Zoom: https://zoom.us/j/3167417956?pwd=Q2NoNWp2a3M2Y2hRSHBKZE1Wcml4Zz09

Whiteboard: https://www.figma.com/board/YsKJZ1HXVmli8U6anK5uIt/2025-Q1-AI-18.-GAN--DCGAN--WGAN?node-id=0-1&p=f&t=IZkN2WKulUQtkC9j-0

Materiāli:

https://arxiv.org/pdf/1406.2661.pdf

https://arxiv.org/pdf/1511.06434.pdf5.2

 


 

 

Kods no iepriekšējiem gadiem: https://share.yellowrobot.xyz/quick/2024-5-28-3965B5B9-F3E9-40A6-8A73-953EE61402BA.zip


Iepriekšējā gada Video:

https://youtube.com/live/rD1R-GkrCxk?feature=share

Video: https://youtube.com/live/84eI97UjrDI?feature=share

Iepriekšējā gada Video: https://youtu.be/ftnIzUdNPYY

 


 

18.2. Implementēt DCGAN

Implementēt DCGAN balstoties uz video instrukcijām

Sagatave: http://share.yellowrobot.xyz/quick/2023-5-18-EB1F688E-2225-47FD-BE8F-7FDE6255AAC4.zip

Iesniegt ekrānšāviņus ar labākajiem rezultātiem un programmas pirmkodu.


18.3 Implementēt WGAN

Implementēt WGAN balstoties uz video instrukcijām, izmantot iepriekšējo sagatavi

Implement WGAN based on video from 5.1. Use previous template.

Iesniegt ekrānšāviņus ar labākajiem rezultātiem un programmas pirmkodu.

 


18.4. Implementēt WGAN ar uzlabojumiem

  1. Implementēt, izmantojot LFW datu kopu seju ģenerēšanai: https://scikit-learn.org/stable/modules/generated/sklearn.datasets.fetch_lfw_people.html

  2. Implementēt GAN hacks (Izvēlēties un pierakstīt pirmkoda komentāros 2 hacks): https://github.com/soumith/ganhacks#authors https://developers.google.com/machine-learning/gan/problems For example: 2.1. Implement soft labels 2.2. Implement Batches in separate passes of optimizer.step for x_real and x_fake

Iesniegt ekrānšāviņus ar labākajiem rezultātiem un programmas pirmkodu.

 

 


image-20250603215748599

image-20250603221045465

 

(1)minGmaxDV(D,G)=1Ni=1N[yilogD(xi)+(1yi)log(1D(xi))](2)LD=1Ni=1N[yilogD(xi)+(1yi)log(1D(xi))](3)LG=1Ni=1NlogD(G(zi))

 

 

image-20250603221153702

 

(4)minGmaxDV(D,G)=Expdata(x)[logD(x)]+Ezpz(z)[log(1D(G(z)))](5)LD=(Expdata(x)[logD(x)]+Ezpz(z)[log(1D(G(z)))])(6)LG=Ezpz(z)[logD(G(z))]

 

image-20250603221717121

 

https://www.researchgate.net/figure/The-progress-in-generating-face-images-of-non-existing-identities-using-GANs-model-and_fig3_340774978

https://www.linkedin.com/pulse/exploring-stylegan-breakthrough-ai-powered-image-arpit-vaghela-6mzrc/

 

https://datascience.stackexchange.com/questions/32671/gan-vs-dcgan-difference

 

Wasserstein GAN

https://arxiv.org/pdf/1701.07875

 

(7)minGmaxDW(D,G)=1Ni=1N[D(xi)D(G(zi))](8)LD=1Ni=1N[D(xi)D(G(zi))](9)LG=1Ni=1ND(G(zi))

⚠️ Šis strādā tikai kopā ar Gradient clipping citādi gradients dažu epohu laikā sabrūk

 

CleanShot 2025-06-03 at 22.12.45

https://jonathan-hui.medium.com/gan-wasserstein-gan-wgan-gp-6a1a2aa1b490

image-20250603221618586

image-20250603221604690

image-20250603221728542

 

image-20250603221748766

 

 

Gan - the more params the better

Discriminator - too many params, loss 0 killed, too little params loss large do not work

Changing learning rates etc. not good idea

 

Might help, but not needed:

  1. Discriminator warmup

  2. Discriminator history

 

Demonstrate mode collapse

 

 

Estimate quality by embeddings - deep metric, inception score etc

 

GAN common problems: https://developers.google.com/machine-learning/gan/problems

GAN hacks https://github.com/soumith/ganhacks#authors

 

Gan - the more params the better

Discriminator - too many params, loss 0 killed, too little params loss large do not work

Changing learning rates etc. not good idea

 

Might help, but not needed:

  1. Discriminator warmup

  2. Discriminator history

 

Demonstrate mode collapse

 

 

Estimate quality by embeddings - deep metric, inception score etc

 

GAN common problems: https://developers.google.com/machine-learning/gan/problems

 

StyleGAN

SOTA šobrid:

StyleGAN3 was officially released by NVIDIA on October 12, 2021 https://nvlabs.github.io/stylegan3/?utm_source=chatgpt.com

 

(10)LD=Expdata[log(1+exp(D(x)))]real term+Ezp(z)[log(1+exp(D(G(z))))]fake term+λR1Expdata[xD(x)22]R1 regularizer
(11)LG=Ezp(z)[log(1+exp(D(G(z))))]generator term+λplEwp(w)yN(0,I)[(JG(w)y2a)2]path-length regularizer

 

Salīdzinājums ar Difussion models

CleanShot 2025-06-03 at 22.25.55

 

https://www.sabrepc.com/blog/Deep-Learning-and-AI/gans-vs-diffusion-models

image-20250603222658225

image-20250603222646743