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

Array reshape error #2

Open
Shailendra-IISc opened this issue Jul 14, 2022 · 5 comments
Open

Array reshape error #2

Shailendra-IISc opened this issue Jul 14, 2022 · 5 comments

Comments

@Shailendra-IISc
Copy link

Hello sir/Ma`am,

Thank you for sharing the important code for scientific research.

I have 21 images with size 1280 x 960 pixels and 13 sample masks with size 64 x 64 pixels. I installed all the dependencies as specified in the 'requirements.txt' file. However, when I run the most recent program, I got the following error message:

File “WassersteinGAN.py”, line 207, in init
self.train_images = (self.train_images.reshape((self.train_images.shape[0], 64, 64, 1)).astype(“float32”) – 127.5)/127.5
ValueError: cannot reshape array of size 851968 into shape (52,64,64,1)

Please let me know if I can fix the above error.

Regards,
Shailendra Kumar Verma

@Shailendra-IISc
Copy link
Author

I converted the mask images from 32 bit to 8 bit. Then, the code runs successfully.

@pramethg
Copy link

Dear @Shailendra-IISc Sir,
Can you please provide the method by which you have created the 8-bit Image masks.
Thank you.

@Shailendra-IISc
Copy link
Author

I used Paint.NET software to save the mask image as 8-bit type. Please make sure that the background is black and the mask is white.

@pramethg
Copy link

In addition to that, while training(the Wasserstein GAN) are you experiencing negative loss corresponding to the Discriminator?

@bruehle
Copy link
Collaborator

bruehle commented Jul 22, 2022

@Shailendra-IISc : Yes, the masks should be single-channel black&white images (i.e., 8 bit). I should probably add this to the documentation, or just change the code so that it binarizes the masks before attempting to use them for training the WGAN. I am glad it works now for you.

@pramethg: Yes, a negative loss in a Wasserstein GAN with Gradient Penalty is "normal". You can find more detailed information about this loss in general (i.e., the idea behind it, how it is calculated, and how it can be interpreted e.g. for detecting overfitting) in Reference 22 of our paper (Gulrajani, I., Ahmed, F., Arjovsky, M., Dumoulin, V. & Courville, A. in Advances in Neural Information Processing Systems 30 Vol. 30 Advances in Neural Information Processing Systems (eds I. Guyon et al.) (Neural Information Processing Systems (Nips), 2017), or the "corresponding" paper of the same authors on arxiv https://arxiv.org/pdf/1704.00028.pdf ), and you can also see how exactly the loss is implmented by looking at the source code of the WassersteinGAN.py file.

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