Skip to content

Instantly share code, notes, and snippets.

@ihoromi4
Last active February 5, 2020 11:50
Show Gist options
  • Save ihoromi4/dd2ed8d78f30ce8ccefe2f6bcb2871f1 to your computer and use it in GitHub Desktop.
Save ihoromi4/dd2ed8d78f30ce8ccefe2f6bcb2871f1 to your computer and use it in GitHub Desktop.
pytorch - get nn.Module device method
from torch import nn
class NN(nn.Module):
def device(self):
return next(self.parameters()).device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment