0

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?

Soomin Lee
  • 15
  • 4
  • 1
    I'm voting to close this question as off-topic because [it is about machine learning rather than software development](https://meta.stackoverflow.com/q/291009/1233251). You may find that there are many questions about generate adversarial networks on both [Cross Validated](//stats.stackexchange.com) and [DataScience.SE](//datascience.stackexchange.com). – E_net4 Dec 19 '17 at 14:06
  • You also seem to show a misconception: the output of a convolutional neural network is not always a vector a class probabilities. It is usually only so in a multi-class problem, when applying a softmax activation at the head of the network. – E_net4 Dec 19 '17 at 14:08

2 Answers2

1

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.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
0

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

Uzzal Podder
  • 2,925
  • 23
  • 26