发现在使用如下torch.nn.DataParallel,原有模型的字典结构会发生一定变化
model = Model()
if torch.cuda.device_count() > 1:
model = nn.DataParallel(model,device_ids=[0,1,2
使用torch.nn.DataParallel后,模型的字典结构会改变,原本的属性被嵌套到`module`属性下。在访问模型参数时,需通过self._model.module进行操作。
发现在使用如下torch.nn.DataParallel,原有模型的字典结构会发生一定变化
model = Model()
if torch.cuda.device_count() > 1:
model = nn.DataParallel(model,device_ids=[0,1,2
1988

被折叠的 条评论
为什么被折叠?