Skip to content

Instantly share code, notes, and snippets.

@tuzhucheng
Last active November 14, 2017 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuzhucheng/0c39850b138225791752d0e336381d8f to your computer and use it in GitHub Desktop.
Save tuzhucheng/0c39850b138225791752d0e336381d8f to your computer and use it in GitHub Desktop.
import torch.onnx
from torch.autograd import Variable
import torch.nn as nn
inp = Variable(torch.LongTensor([1,2,3]))
class MyModel(nn.Module):
def __init__(self):
super(MyModel, self).__init__()
self.embedding = nn.Embedding(100, 300)
def forward(self, x):
out = self.embedding(x)
return out
model = MyModel()
out = model(inp)
torch.onnx.export(model, inp, 'embedding_only.onnx', verbose=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment