pytorch列表添加模块

在使用pytorch将多个模块添加到列表时不能使用简单的list,需要使用torch.nn.ModuleList,否则框架无法跟踪到模块且不能使用model.cuda()将模型转移到GPU上,会产生以下错误 RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 ‘self’
相关文章
相关标签/搜索