hpkim0512 / Deep_MRI_Unet

17 stars 11 forks source link

Testing the network does not work #3

Closed vegarant closed 5 years ago

vegarant commented 6 years ago

https://github.com/hpkim0512/Deep_MRI_Unet/blob/a4b86db5b23f389761d6ed40d5a503bac385a33b/model.py#L90

It seems as if self.is_train is False, then the grad variable will not exist and the build_model(...) function fails.

dedmari commented 6 years ago

Execute this block of code after checking whether is_train is true, as optimizer is used only during training.

hpkim0512 commented 6 years ago

When you want to test the trained networks, the grad variables don't need to exist. It is used only to update the trainable weights during training. There is no problem to run build_model(...) without grad variables. If there is any error on your environment, let me know.

vegarant commented 6 years ago

Eh, the problem is that the grad variable is only initialized on https://github.com/hpkim0512/Deep_MRI_Unet/blob/a4b86db5b23f389761d6ed40d5a503bac385a33b/model.py#L81

So if the if-test enters the else statement the grad variable never gets initialized. Then you get an error on the line I mentioned above.

I get that computing the gradient is completely meaningless if you would like to test the network.

Does running the line below (as suggested by the readme file) work for you with the current version of the code. I get an error at least.

python main.py --is_train=False --ckpt_dir=model --test_set=test_set
hpkim0512 commented 6 years ago

Ah... I see what you mean. The lines 87-90 should be placed in the state if self.is_train. I'll correct that. Thank you!

vegarant commented 6 years ago

Nice. Could you also check that the pre-trained model provided in the README file works as intended. The images the network produces for me at the moment seems really bad.