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’
相關文章
相關標籤/搜索