Reputation: 15
I studying about DCGAN, and I wonder something about it.
In Ian Goodfellow's natural GAN, discriminator Model outputs one scalar value what means the probability. But DCGAN's discriminator has designed with CNN architecture. I know that CNN's output is vector of class probabilities.
So how discriminator works on DCGAN? And what output of DCGAN's discriminator is?
Upvotes: 0
Views: 754
Reputation: 3205
Discriminator D takes a 3x64x64(for example) input image, processes it through a series of Conv2d, BatchNorm2d, and LeakyReLU layers, and outputs the final probability through a Sigmoid activation function.
Let's see an sample code to understand it's input and output.
class Discriminator(nn.Module):
def __init__(self, ngpu):
super(Discriminator, self).__init__()
self.ngpu = ngpu
self.main = nn.Sequential(
nn.Conv2d(nc, ndf, 4, 2, 1, bias=False),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv2d(ndf, ndf*2, 4, 2, 1, bias=False),
nn.BatchNorm2d(ndf*2),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv2d(ndf*2, ndf*4, 4, 2, 1, bias=False),
nn.BatchNorm2d(ndf*4),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv2d(ndf*4, ndf*8, 4, 2, 1, bias=False ),
nn.BatchNorm2d(ndf*8),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv2d(ndf*8, 1, 4, 1, 0, bias=False),
nn.Sigmoid()
)
def forward(self, input):
return self.main(input)
For more details, visit here
Upvotes: 0
Reputation: 136227
See Image Completion with Deep Learning in TensorFlow for a long answer.
In short: Suppose you make a CNN which has n filters of the size of its input and valid-padding. Then the output will be of shape n x 1 x 1. Then you can apply softmax to that shape and you have the probabilities in the channels.
You might also want to read 2.2.1. Convolutional Layers of my Masters thesis.
Upvotes: 1