Skip to content

Instantly share code, notes, and snippets.

@YimianDai
Created July 23, 2019 05:24
Show Gist options
  • Save YimianDai/fb2453359d341bc3fbaec8098d139a60 to your computer and use it in GitHub Desktop.
Save YimianDai/fb2453359d341bc3fbaec8098d139a60 to your computer and use it in GitHub Desktop.
PyTorch-MXNet Cheat Sheet

PyTorch and MXNet

PyTorch MXNet
.item() .asscalar()
.numpy() .asnumpy()
.from_numpy() .array()
device = torch.device("cuda") ctx = mx.gpu()
x = x.to(device) x = x.as_in_context(ctx)

Specify a variable need autograd in PyTorch

x = torch.ones(2, 2, requires_grad=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment