Construa uma DCGAN
GAN convolucional para geração de imagens
Construa uma DCGAN é uma aula grátis de Deep Learning Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Deep Learning Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Deep Learning Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
What DCGAN Adds
A DCGAN is a GAN built from convolutional layers. It swaps dense layers for convolutions, which makes it great at generating realistic images. 🖼️
Generator Grows the Image
The generator uses transposed convolutions to upsample a tiny latent vector step by step into a full-size image.
nn.ConvTranspose2d(100, 256, 4, 1, 0)Discriminator Shrinks the Image
The discriminator does the reverse: strided convolutions shrink the image down to a single real-or-fake score.
nn.Conv2d(3, 64, 4, 2, 1)Batch Norm Stabilizes
DCGAN puts batch normalization between layers in both networks. It keeps activations healthy and makes training far more stable.
nn.BatchNorm2d(256)ReLU in the Generator
The generator uses ReLU activations on its hidden layers to keep gradients flowing as the image is built up.
nn.ReLU(True)LeakyReLU in the Discriminator
The discriminator prefers LeakyReLU, which lets a small signal through for negative values and avoids dead neurons.
nn.LeakyReLU(0.2, inplace=True)Tanh on the Output
The generator ends with Tanh, squeezing pixels into the range minus one to one to match normalized training images.
nn.Tanh()Sigmoid for the Verdict
The discriminator finishes with a sigmoid, turning its final feature into a probability between zero and one.
nn.Sigmoid()Weight Initialization
DCGAN starts weights from a small normal distribution centered near zero. Good init helps both networks train smoothly from the first step.
nn.init.normal_(m.weight, 0.0, 0.02)Pick the Latent Size
The latent dimension, often 100, sets how many random numbers seed each image. Larger latents give the generator more room to vary.
nz = 100Watch Samples as You Train
Save a grid of generated images every few epochs. Watching them get sharper is how you confirm a DCGAN is actually learning.
Quick Check
Which activation belongs at the very end of the generator?
Recap: Building a DCGAN
You assembled a DCGAN: transposed convolutions grow images, strided convolutions judge them, and batch norm keeps it all stable. 🛠️
Perguntas Frequentes
A aula “Construa uma DCGAN” é grátis?
Sim — o texto completo de “Construa uma DCGAN” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Deep Learning Academy, atualize para CoddyKit PRO. O curso de Deep Learning Academy inclui 4 aulas no total.
O que vou aprender em “Construa uma DCGAN”?
GAN convolucional para geração de imagens Você pratica Deep Learning Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Deep Learning Academy?
Nenhuma experiência prévia é necessária. Deep Learning Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.
Quanto tempo leva a aula “Construa uma DCGAN”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Deep Learning Academy?
Sim. Cada aula de Deep Learning Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Gerador vs Discriminador: O Jogo
- A Perda Adversarial
- Construa uma DCGAN
- Colapso de Modo e Truques de Estabilização