torch中将网络加载进GPU的两种方式

对于网络模型的实例化对象net

一、

import torch
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
net.to(device)

二、

import torch
net.cuda()

 

posted @ 2019-05-31 10:46  车路历程  阅读(601)  评论(0编辑  收藏  举报