aws / aws/amazon-sagemaker-examples
HOW TO: convert SageMaker model (after training job) to ONNX for using in other platform.
- Dominant language
- Jupyter Notebook
- Stars
- 11k
- Forks
- 7k
- Avg merge
- 8h 29m
- Merged PRs (30d)
- 8
Description
After a training job (**Amazon SageMaker built-in algorithm - Object detection - VGG-16**) I ended up with a model artifact in a compressed archive model.tar.gz.
Inside there are what I suppose to be MXnet model files, so I tried to convert it following this tutorial: https://github.com/onnx/tutorials/blob/master/tutorials/MXNetONNXExport.ipynb
and this:
https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-onnx-mxnet-cntk.html
I run the tutorial in a **SageMaker Jupyter notebook instance**.
Using the data provided by the github.com/onnx tutorial the conversion **succeed**.
While using the tata in model.tar.gz generated by sagemaker training job the conversion **failed**.
Here are my changes:
```
sym = './model_algo_1-symbol.json'
params = './model_algo_1-0000.params'
input_shape = (1,3,300,300)
```
I suppose the input_shape to be correct, since in Hyperparameters the image_shape = 300.
And this is the **error raised**
`MXNetError: Error in operator multibox_target: [14:36:32] src/operator/contrib/./multibox_target-inl.h:224: Check failed: lshape.ndim() == 3 (-1 vs. 3) : Label should be [batch, num_labels, label_width] tensor`
Verbose:
```
infer_shape error. Arguments:
data: (1, 3, 300, 300)
conv3_2_weight: (256, 256, 3, 3)
fc7_bias: (1024,)
multi_feat_3_conv_1x1_conv_weight: (128, 512, 1, 1)
conv4_1_bias: (512,)
conv5_3_bias: (512,)
relu4_3_cls_pred_conv_bias: (16,)
multi_feat_2_conv_3x3_relu_cls_pred_conv_weight: (24, 512, 3, 3)
relu4_3_loc_pred_conv_bias: (16,)
relu7_cls_pred_conv_weight: (24, 1024, 3, 3)
conv3_3_bias: (256,)
multi_feat_5_conv_3x3_relu_cls_pred_conv_weight: (16, 256, 3, 3)
conv4_3_weight: (512, 512, 3, 3)
conv1_2_bias: (64,)
multi_feat_2_conv_3x3_relu_cls_pred_conv_bias: (24,)
multi_feat_4_conv_3x3_conv_weight: (256, 128, 3, 3)
conv4_1_weight: (512, 256, 3, 3)
relu4_3_scale: (1, 512, 1, 1)
multi_feat_4_conv_3x3_conv_bias: (256,)
multi_feat_5_conv_3x3_relu_cls_pred_conv_bias: (16,)
conv2_2_weight: (128, 128, 3, 3)
multi_feat_3_conv_3x3_relu_loc_pred_conv_weight: (24, 256, 3, 3)
multi_feat_5_conv_3x3_conv_bias: (256,)
conv5_1_bias: (512,)
multi_feat_3_conv_3x3_conv_bias: (256,)
conv2_1_bias: (128,)
conv5_2_weight: (512, 512, 3, 3)
multi_feat_5_conv_3x3_relu_loc_pred_conv_weight: (16, 256, 3, 3)
multi_feat_4_conv_3x3_relu_loc_pred_conv_weight: (16, 256, 3, 3)
multi_feat_2_conv_3x3_conv_weight: (512, 256, 3, 3)
multi_feat_2_conv_1x1_conv_bias: (256,)
multi_feat_2_conv_1x1_conv_weight: (256, 1024, 1, 1)
conv4_3_bias: (512,)
relu7_cls_pred_conv_bias: (24,)
fc6_bias: (1024,)
conv2_1_weight: (128, 64, 3, 3)
multi_feat_2_conv_3x3_conv_bias: (512,)
multi_feat_2_conv_3x3_relu_loc_pred_conv_weight: (24, 512, 3, 3)
multi_feat_5_conv_1x1_conv_bias: (128,)
relu7_loc_pred_conv_bias: (24,)
multi_feat_3_conv_3x3_relu_loc_pred_conv_bias: (24,)
conv3_3_weight: (256, 256, 3, 3)
conv1_2_weight: (64, 64, 3, 3)
multi_feat_2_conv_3x3_relu_loc_pred_conv_bias: (24,)
conv1_1_bias: (64,)
multi_feat_4_conv_3x3_relu_cls_pred_conv_bias: (16,)
conv4_2_weight: (512, 512, 3, 3)
conv5_3_weight: (512, 512, 3, 3)
relu7_loc_pred_conv_weight: (24, 1024, 3, 3)
multi_feat_3_conv_3x3_conv_weight: (256, 128, 3, 3)
conv3_1_weight: (256, 128, 3, 3)
multi_feat_4_conv_3x3_relu_cls_pred_conv_weight: (16, 256, 3, 3)
relu4_3_loc_pred_conv_weight: (16, 512, 3, 3)
multi_feat_5_conv_3x3_conv_weight: (256, 128, 3, 3)
fc7_weight: (1024, 1024, 1, 1)
conv4_2_bias: (512,)
multi_feat_3_conv_3x3_relu_cls_pred_conv_weight: (24, 256, 3, 3)
multi_feat_3_conv_3x3_relu_cls_pred_conv_bias: (24,)
conv2_2_bias: (128,)
conv5_1_weight: (512, 512, 3, 3)
multi_feat_3_conv_1x1_conv_bias: (128,)
multi_feat_4_conv_3x3_relu_loc_pred_conv_bias: (16,)
conv1_1_weight: (64, 3, 3, 3)
multi_feat_4_conv_1x1_conv_bias: (128,)
conv3_1_bias: (256,)
multi_feat_5_conv_3x3_relu_loc_pred_conv_bias: (16,)
multi_feat_4_conv_1x1_conv_weight: (128, 256, 1, 1)
fc6_weight: (1024, 512, 3, 3)
multi_feat_5_conv_1x1_conv_weight: (128, 256, 1, 1)
conv3_2_bias: (256,)
conv5_2_bias: (512,)
relu4_3_cls_pred_conv_weight: (16, 512, 3, 3)
```
Why isn't working as expected?
Any option to use the trained model in other platforms?
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.