torch多卡模型转单卡

from collections import OrderedDict
state_dict1 = torch.load(self.model1)
module_state_dict1 = OrderedDict()
for k, v in state_dict1.items():
	name = k[7:]
	module_state_dict1[name] = v
	self.model = self.model.cuda()        	
	self.model.load_state_dict(module_state_dict1, strict=True)
	#self.model = self.model.cuda()
	self.model.eval()

上一篇:[Python]小甲鱼Python视频第026课(字典:当索引不好用时2)课后题及参考解答


下一篇:列表与字典之间的转换