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

Ratio between fake and reconstructed #32

Open
PoRuSung opened this issue May 22, 2024 · 10 comments
Open

Ratio between fake and reconstructed #32

PoRuSung opened this issue May 22, 2024 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@PoRuSung
Copy link

PoRuSung commented May 22, 2024

Hi, thanks for the great work ! I want to ask about if I want to change the ratio of fake and reconstructed images while training what should I do? Can you help me with that? (previously I've used your code to train a model and got low reconstruct loss but the fake loss is not as low as reconstruct loss)

@usert5432 usert5432 self-assigned this May 22, 2024
@usert5432 usert5432 added the question Further information is requested label May 22, 2024
@usert5432
Copy link
Collaborator

Hi @PoRuSung,

Thank you for your interest in our work!

I want to ask about if I want to changing the ratio of fake and reconstructed images while training what should I do? Can you help me with that? (previously I've used your code to train a model and got low reconstruct loss but the fake loss is not as low as reconstruct loss)

If you simply want to change the ratio (importance) of reconstruction and translation losses, then you can adjust lambda-cycle argument of the corresponding scripts. Increasing lambda-cycle parameter will increase the importance of the reconstruction images.

However, I am not sure if that answers your question. In particular, if you are referring to a runtime ratio of fake and reco losses, or some other ratio, then a different procedure may be needed. If it is the case, could you please elaborate on the problem you encounter, and we will try to diagnose it.

@PoRuSung
Copy link
Author

@usert5432 Hi, thanks for your reply!
Currently my purpose is to change the ratio of reconstruction and translation losses and I've set lambda-cycle to 0.0 and start training.

if you are referring to a runtime ratio of fake and reco losses, or some other ratio, then a different procedure may be needed.

But I wonder the difference between the message you mentioned above and the reconstruction and translation losses, currently my understanding isn't sufficient to distinguish these two, would you kindly explain a little bit for me? Thank you very much.

@usert5432
Copy link
Collaborator

Hi @PoRuSung,

Thank you for the elaboration.

Currently my purpose is to change the ratio of reconstruction and translation losses and I've set lambda-cycle to 0.0 and start training.

Unfortunately, setting lambda-cycle to 0 will likely break the training. You need to use some non-zero values.

But I wonder the difference between the message you mentioned above and the reconstruction and translation losses, currently my understanding isn't sufficient to distinguish these two, would you kindly explain a little bit for me? Thank you very much.

lambda-cycle controls the "importance" of reconstruction loss relative to the fake loss. When I say "importance", I mean it in the abstract sense. So, the higher lambda-cycle is -- the more attention CycleGAN will pay to the reconstruction loss relative to the fake loss.

However, this abstract "importance" does not directly translate to the actual numerical values of the losses. For example, if one trains CycleGAN with lambda-cycle = 1 one can observe the following losses: gen_ab = 0.26, reco_a = 0.2. At the same time, increasing lambda-cycle to 10 will make the reconstruction loss more "important", but one may still observe the same numerical values, e.g. gen_ab = 0.26, reco_a = 0.2.

Now, if you care about "importance" of fake and reco losses, then lambda-cycle is a parameter to adjust. If you care about their numerical values, then I do not not have any good suggestions on how to adjust their numerical ratio.

@PoRuSung
Copy link
Author

Hi @usert5432 ,

Thank you for your detail explanation, I'll try using lambda-cycle =1.0 , thanks again!

@PoRuSung
Copy link
Author

PoRuSung commented Jun 5, 2024

Hi @usert5432 ,

I would like to ask another question about training image size, I set the training image size to 960*592 (which is dividable by 16)
image
image

but encountered error msg like
image
could you please help me figure this out? Thank you!

@usert5432
Copy link
Collaborator

Hi @PoRuSung,

could you please help me figure this out? Thank you!

Sure, I suspect this issue may be happening because you perform a parameter transfer from a model that was pre-trained on images of size (256, 256)?

Could you please double check that and/or share transfer configuration?

@PoRuSung
Copy link
Author

PoRuSung commented Jun 6, 2024

d2b_lambda_cyc_zero_translation.zip

Hi @usert5432 ,
Thank you for your reply, the attachment is my translation python file, the transfer configuration is using the afhq/pretrain
image

@usert5432
Copy link
Collaborator

Hi @PoRuSung,

Thank you for sharing the config file! Indeed, it looks like the training attempts to use pre-trained encoders. However, "afhq/pretrain" was pretrained on images of size (256, 256) and thus cannot be simply transferred to images of size (592, 960).

I think, this error can be fixed by disabling the pre-training (e.g. passing --no-pretrain option to the training script)

@PoRuSung
Copy link
Author

PoRuSung commented Jun 7, 2024

Hi @usert5432 ,

Thanks for your reply! I'm just wondering training without using pre-trained model would affect the training performance.

@usert5432
Copy link
Collaborator

Thanks for your reply! I'm just wondering training without using pre-trained model would affect the training performance.

Yes, unfortunately, removing the pre-training will likely worsen the performance. You may want to run a custom pre-training on large images.

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

No branches or pull requests

2 participants