这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,11 @@ def main():
print("Saving model to {}".format(model_checkpoint + ".last"))
torch.save(rencoder.state_dict(), model_checkpoint + ".last")

# save to onnx
dummy_input = Variable(torch.randn(params['batch_size'], data_layer.vector_dim).type(torch.float))
torch.onnx.export(rencoder.float(), dummy_input.cuda() if use_gpu else dummy_input,
model_checkpoint + ".onnx", verbose=True)
print("ONNX model saved to {}!".format(model_checkpoint + ".onnx"))

if __name__ == '__main__':
main()