style-based-gan-pytorch
style-based-gan-pytorch copied to clipboard
question about variable 'g_running'
Hi , what a wonderful project! I successfully run it on my computer! I just wonder why the following code in Line 106, train.py does not raise any error like "there is no deifnition of variable 'g_running'":
torch.save( { 'generator': generator.module.state_dict(), 'discriminator': discriminator.module.state_dict(), 'g_optimizer': g_optimizer.state_dict(), 'd_optimizer': d_optimizer.state_dict(), 'g_running': g_running.state_dict(), }, f'checkpoint/train_step-{ckpt_step}.model', )
I found the defination of variable 'g_running' only exists in "if name == 'main': ", while the arguments to the funtion "train()" in train.py do not contain "g_running", and there is no definition about variable "g_running" in the funtion "train()". I do not understand why it does not raise any error. Thanks
Because you will use train() inside of if __name__ == '__main__'. Anyway it would be better to use it as an explicit parameters.