转载自:https://blog.csdn.net/jacke121/article/details/93592340
尊重原创,请读原文。
inputs = Variable(torch.randn(2,2))
inputs.is_cuda # will return false
inputs = Variable(torch.randn(2,2).cuda())
inputs.is_cuda # returns true
判断变量类型:下面两种方法都行
if isinstance(downsample, torch.nn.Module):
# if torch.type(downsample) != torch.IntTensor: