Open GreenLimeSia opened 4 years ago
You should make code for it. But I think it could be not very easy as optimizer state_dict is somewhat complicated.
Thanks for your reply! I will do it soon!
@GreenLimeSia Have you managed to export "optim_G" and "optim_D"?
@abelghazinyan I do not export "optim_G" and "optim_D", but I have another scheme for using "optim_G" and "optim_D" in PyTorch. We can set it manually like this:
`g_ckpt = torch.load(args.g_ckpt, map_location=lambda storage, loc: storage)
# g_args = g_ckpt['args']
args.size = 1024 # g_args.size
args.latent = 512 # g_args.latent
args.n_mlp = 8 # g_args.n_mlp
args.channel_multiplier = 2 # g_args.channel_multiplier`
For optimizer parameters, we can choose not to load it for the first time when we use it, then train the model and save the new parameters, then load it. From the results of my experiment, It also works well by using this scheme.
I can generate 1024x1024 images using the instructions provided in https://github.com/bryandlee/FreezeG, but the problem is that I want to finetune that model and in train.py "optim_G" and "optim_D" are required
Hmm hard to know the use case of yours. Official tensorflow implementations does not includes optimizer states in the checkpoints, so by default you cannot get optimizer states from it. And I think you don't need to use optimizer states for most use cases. You can just skip loading state dict of optimizers.
I am trying to do transfer learning on the 1024x1024 model with https://github.com/bryandlee/FreezeG, and there optimizer states are required to continue finetuning on the pretrained network.
Is reusing optimizer states crucial to FreezeG? I think it will be not very problematic to run without optimizer states.
I want to convert ckpt = {"g_ema": state_dict, "latent_avg": latent_avg, "args": tf_args, "optim_G": optm_G.state_dict, "optim_D": optm_D.state_dict}? But I don't know how to do this? Would you mind help me ?