-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Can not transfer-learning with different number of "classes" #156
Comments
Answer in #98 already but for non-conditioning vs conditioning. Any idea how to transfer learning between 2 conditioning-models ? Would something like this work? Where do we apply this change ? _def on_load_checkpoint(self, checkpoint: dict) -> None:
Thanks, |
We can transfer learning between 2 conditional models with different number of classes, but in this case we will not copy the parameters of the embedding layer "mapping.embed" in G and D (its shape depends on the number of classes taken as an input). For this, you need to modify the function "copy_params_and_buffers" in "torch_utils/misc.py" in such a way that it does not copy all the parameters of the pretrained model.
|
https://github.com/Gass2109 I have changed the code into what you proposed, and got errors: ------------ ERROR --------------- File ".\training\networks.py", line 602, in forward Any hint please. Thanks, |
My BAD !!! I screwed up batch size to 20, should divide by 8, change it to 24 and it works now, thank you. Steve |
have you managed to implement stylegan2 into lightning? Do you have a repo for this? This would be great! |
Describe the bug
Do not seem to be able to transfer learning from my own pretrained model (both are conditional-training models). The pretrained model has 20 "conditional classes" and was performing well. I then tried to use the same model to transfer learning to another dataset but with 34 "conditional classes" and got errors:
Resuming from "./results/CHECKPOINT/network-snapshot-001400.pkl"
Traceback (most recent call last):
File "train_GPU_0.py", line 547, in
main() # pylint: disable=no-value-for-parameter
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 829, in call
return self.main(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\ProgramData\Anaconda3\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "train_GPU_0.py", line 540, in main
subprocess_fn(rank=0, args=args, temp_dir=temp_dir)
File "train_GPU_0.py", line 389, in subprocess_fn
training_loop.training_loop(rank=rank, **args)
File "D:\AI\Furnitures\dataset_AA\GAN_DATA_for_training\GAN_data_NEW_COMBINED_HOUSE_ROOM\Individual_Style_to_Context_dataset_corrected\Contemporary\StyleGANV2-pytorch\training\training_loop.py", line 163, in training_loop
misc.copy_params_and_buffers(resume_data[name], module, require_all=False)
File "D:\AI\Furnitures\dataset_AA\GAN_DATA_for_training\GAN_data_NEW_COMBINED_HOUSE_ROOM\Individual_Style_to_Context_dataset_corrected\Contemporary\StyleGANV2-pytorch\torch_utils\misc.py", line 160, in copy_params_and_buffers
tensor.copy(src_tensors[name].detach()).requires_grad_(tensor.requires_grad)
RuntimeError: The size of tensor a (34) must match the size of tensor b (20) at non-singleton dimension 1_
To Reproduce
Have tried a few time with different dataset, same kind of error.
I though that we should be able to transfer learning regardless of number of class to take advantages of the pretrained weights for the most of network ?
Any help is highly appreciated.
Steve
The text was updated successfully, but these errors were encountered: