Coding CGAN paper model in Keras


I was coding a CGAN model using Keras along with the paper ( and I wanted to try and match the models to exactly what the paper says. I knew the models presented in the paper would be primitive but just wanted to replicate those and see. For example the generator model in the paper mentions this:

In the generator net, a noise prior z with dimensionality 100 was drawn from a uniform distribution within the unit hypercube. Both z and y are mapped to hidden layers with Rectified Linear Unit (ReLu) activation [4, 11], with layer sizes 200 and 1000 respectively, before both being mapped to second, combined hidden ReLu layer of dimensionality 1200. We then have a final sigmoid unit layer as our output for generating the 784-dimensional MNIST samples.

So for this I had the code like this:

def build_generator(self):

       model = Sequential()

       model.add(Dense(200, input_dim=self.latent_dim))


       model.add(Dense(1200, input_dim=self.latent_dim))


       model.add(Dense(, activation='sigmoid'))


       noise = Input(shape=(self.latent_dim,))
       label = Input(shape=(1,), dtype='int32')
       label_embedding = Flatten()(Embedding(self.num_classes, self.latent_dim)(label))

       model_input = multiply([noise, label_embedding])

       img = model(model_input)

       return Model([noise, label], img)

But still I think this not exactly what the paper means. What I understand from the paper is the noise and labels are first fed into two different layers and then combined to one layer.

Does this mean that there should be three separate models inside the generator? Or am I mistaken thinking that? Would like to hear any thoughts on this.


Posted 2018-04-13T03:14:47.773

Reputation: 31

No answers