when i train/test model,arise some problem about load pretrained model .The code in model.py as follow
def initialize_model(self, path=None, train=True):
self.G = RFRNet()
if train:
self.lossNet = VGG16FeatureExtractor()
self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4)
try:
start_iter = load_ckpt(path, [('generator', self.G)], [('optimizer_G', self.optm_G)])
print("here")
if train:
self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4)
print('Model Initialized, iter: ', start_iter)
self.iter = start_iter
except:
print('No trained model, from start')
,and in utils.io---->load_ckpt(),the code as follow
if optimizers is not None:
for prefix, optimizer in optimizers:
optimizer.load_state_dict(ckpt_dict[prefix])
may self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4) should be writen in try???otherwise self.optm_G will be None ,and pretrained model cannot be load .
when i train/test model,arise some problem about load pretrained model .The code in model.py as follow def initialize_model(self, path=None, train=True): self.G = RFRNet() if train: self.lossNet = VGG16FeatureExtractor() self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4) try: start_iter = load_ckpt(path, [('generator', self.G)], [('optimizer_G', self.optm_G)]) print("here") if train: self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4) print('Model Initialized, iter: ', start_iter) self.iter = start_iter except: print('No trained model, from start')
,and in utils.io---->load_ckpt(),the code as follow
if optimizers is not None: for prefix, optimizer in optimizers: optimizer.load_state_dict(ckpt_dict[prefix])
may self.optm_G = optim.Adam(self.G.parameters(), lr = 2e-4) should be writen in try???otherwise self.optm_G will be None ,and pretrained model cannot be load .