Skip to content
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‘t load the trained model #34

Open
upperblacksmith opened this issue May 11, 2021 · 1 comment
Open

can‘t load the trained model #34

upperblacksmith opened this issue May 11, 2021 · 1 comment

Comments

@upperblacksmith
Copy link

when i load the trained model UNet_ResNet18.pth with torch.load(DeepLabV3Plus_ResNet18.pth). a error had occur,the detail as follows.
1
i will appreciate it if you can provide some advices. thanks a lot

@jzx-gooner
Copy link

jzx-gooner commented May 12, 2021

save model like this and you can load your model ignore the ModuleNotFoundError or load your model and resave like this

		# Construct savedict
		#arch = type(self.model).__name__
		#state = {
			# 'arch': arch,
			# 'epoch': epoch,
			# 'logger': self.train_logger,
			#'state_dict': self.model.state_dict(),
			# 'optimizer': self.optimizer.state_dict(),
			# 'monitor_best': self.monitor_best,
			# 'config': self.config
		#}
		state_dict = self.model.state_dict()
		# Save checkpoint for each epoch
		if self.save_freq is not None:	# Use None mode to avoid over disk space with large models
			if epoch % self.save_freq == 0:
				filename = os.path.join(self.checkpoint_dir, 'epoch{}.pth'.format(epoch))
				torch.save(state_dict, filename)
				self.logger.info("Saving checkpoint at {}".format(filename))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants