Aaronx commited on
Commit
0e0172b
1 Parent(s): e1f0708

Upload 2 files

Browse files
Files changed (2) hide show
  1. PyTorchTraining.py +24 -0
  2. pytorch_model.pt +3 -0
PyTorchTraining.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch.onnx
2
+
3
+ #Function to Convert to ONNX
4
+ def Convert_ONNX():
5
+
6
+ # set the model to inference mode
7
+ model.eval()
8
+
9
+ # Let's create a dummy input tensor
10
+ dummy_input = torch.randn(1, input_size, requires_grad=True)
11
+
12
+ # Export the model
13
+ torch.onnx.export(model, # model being run
14
+ dummy_input, # model input (or a tuple for multiple inputs)
15
+ "ImageClassifier.onnx", # where to save the model
16
+ export_params=True, # store the trained parameter weights inside the model file
17
+ opset_version=10, # the ONNX version to export the model to
18
+ do_constant_folding=True, # whether to execute constant folding for optimization
19
+ input_names = ['modelInput'], # the model's input names
20
+ output_names = ['modelOutput'], # the model's output names
21
+ dynamic_axes={'modelInput' : {0 : 'batch_size'}, # variable length axes
22
+ 'modelOutput' : {0 : 'batch_size'}})
23
+ print(" ")
24
+ print('Model has been converted to ONNX')
pytorch_model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89c70e808d1783b6c07911306e106aaf0d4f7f3da8c61078b99ff7f8929a26f4
3
+ size 116861841