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

Change dataset with image size not 28*28, Can't train it. #33

Closed
ghost opened this issue May 6, 2018 · 5 comments
Closed

Change dataset with image size not 28*28, Can't train it. #33

ghost opened this issue May 6, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented May 6, 2018

When I change dataset form mnist to cifar10(with images 32323), and changed code as:

self.img_rows = 32 # 28 to 32
self.img_cols = 32 # 28 to 32
self.channels = 3 # 1 to 3
```.

But I got an error


` _ValueError: Error when checking input: expected input_1 to have shape (32, 32, 3) but got array with shape (28, 28, 3)_`.


I found it's because that shape of gen_imgs is (28,28,3) in where 

`gen_imgs = self.generator.predict(noise)` in `def train()
`.
Could you tell me how to fix it?
@miranthajayatilake
Copy link
Contributor

In case you're using the gan_rgb.py code, change this line as well.

X_train = self.get_batch(glob(os.path.join('data', '*.jpg'))[:5000], 28, 28, 'RGB')

@ghost
Copy link
Author

ghost commented May 6, 2018

Thank you, but i have use ccgan and dcgan. How could I fix in those files.

@eriklindernoren
Copy link
Owner

Hi. For DCGAN you'll need to change:

model.add(Dense(128 * 7 * 7, activation="relu", input_shape=(self.latent_dim,)))
model.add(Reshape((7, 7, 128)))

to

model.add(Dense(128 * 8 * 8, activation="relu", input_shape=(self.latent_dim,)))
model.add(Reshape((8, 8, 128)))

@2017develper
Copy link

Keras-GAN/aae/adversarial_autoencoder.py
i want to save the model how i can do it

@miranthajayatilake
Copy link
Contributor

Use name_of_your_model.save_weights('name_of_your_model.h5')

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