Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a question about gcgan network #3

Closed
0AlvinLO0 opened this issue Oct 13, 2017 · 9 comments
Closed

a question about gcgan network #3

0AlvinLO0 opened this issue Oct 13, 2017 · 9 comments

Comments

@0AlvinLO0
Copy link

hello,Erik, thanks for your sharing of these kinds of GAN, and I wonder if my data is 3 channel color images like cifar, how to apply it, for if I just change the size and channel it arise an error 'number of input channels does not match corresponding dimension of filter, 1 != 3'

@eriklindernoren
Copy link
Owner

eriklindernoren commented Oct 13, 2017

Hi, thanks! I'm assuming you're referring to DCGAN? If so hopefully all you need to do is change:
model.add(Conv2D(1, kernel_size=3, padding="same"))
to
model.add(Conv2D(self.channels, kernel_size=3, padding="same"))
on line 67.

@0AlvinLO0
Copy link
Author

oh yeah dcgan, yes the network works, thanks a lot for your help~~

@flyfj
Copy link

flyfj commented Dec 5, 2017

the input dimension for cifar (32) is different from mnist (28), how can it be changed to generate that size?

@eriklindernoren
Copy link
Owner

Change
self.img_rows = 28
self.img_cols = 28
self.channels = 1
to
self.img_rows = 32
self.img_rows = 32
self.channels = 3
and also make the changes I suggested in my answer above.

@flyfj
Copy link

flyfj commented Dec 6, 2017

thanks for the reply.
i think i also need to modify 'model.add(Dense(128 * 8 * 8))' to make the generator produce 32x32 image, otherwise it produces 28x28. is that expected?

@eriklindernoren
Copy link
Owner

Yeah, that is correct. Change these lines:
model.add(Dense(128 * 7 * 7, activation="relu", input_shape=noise_shape))
model.add(Reshape((7, 7, 128)))
to
model.add(Dense(128 * 8 * 8, activation="relu", input_shape=noise_shape))
model.add(Reshape((8, 8, 128)))

@flyfj
Copy link

flyfj commented Dec 6, 2017

is there a formula to calculate the layer dimension given an arbitrary input image size? what reference/paper do you use to implement the network?

@eriklindernoren
Copy link
Owner

eriklindernoren commented Dec 6, 2017

A suggestion I often see is to start with a shallow network, get something that works and then expand on that. There is no recipe when it comes to building the network's architecture that guarantees good results though, and it's extra tricky when it comes to GANs. For this example I build the network based of the architecture in the paper and some experimentation. I can recommend this page: https://github.com/soumith/ganhacks (from one of the authors of DCGAN).

@flyfj
Copy link

flyfj commented Dec 6, 2017

thanks for the guide, very helpful. agree on starting with shallow ones that could fit the data first.
excellent work on the implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants