Getting trouble while converting .model to .onnx

Hello, I have modified AlexNet model trained with PyTorch. The trained file has .model extension file. I want to convert it to ONNX model and export to c++.
I tried the basic convertion code but it gives error:

import torch.onnx

device = torch.device('cpu')
model = torch.load('SiamRPN.model', map_location=device)
dummy_input = torch.randn(1, 3, 224, 224)

torch.onnx.export(model, dummy_input,"my_onnx_model.onnx")

When I run the last line with Python 2, it gives error like below. What is the problem here?

Traceback (most recent call last):
  File "", line 7, in <module>
    torch.onnx.export(model, dummy_input,"my_onnx_model.onnx")
  File "/usr/local/lib/python2.7/dist-packages/torch/onnx/", line 32, in export
    return utils.export(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/onnx/", line 170, in export
    example_outputs=example_outputs, strip_doc_string=strip_doc_string, dynamic_axes=dynamic_axes)
  File "/usr/local/lib/python2.7/dist-packages/torch/onnx/", line 423, in _export
    _retain_param_name, do_constant_folding)
  File "/usr/local/lib/python2.7/dist-packages/torch/onnx/", line 317, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "/usr/local/lib/python2.7/dist-packages/torch/onnx/", line 267, in _trace_and_get_graph_from_model
    orig_state_dict_keys = _unique_state_dict(model).keys()
  File "/usr/local/lib/python2.7/dist-packages/torch/jit/", line 244, in _unique_state_dict
    state_dict = module.state_dict(keep_vars=True)
AttributeError: 'OrderedDict' object has no attribute 'state_dict'