The following is my code:
import torch
import torch.onnx
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
import torch.onnx as torch_onnx
from torch import FloatTensor
import numpy as np
from typing import Tuple, Callable, Optional
Internal Modules
#from util_funcs import UFloatTensor, ULongTensor
#from util_layers import Conv, SepConv, Dense, EndChannels
from pointnet import TransformationNet,BasePointNet,ClassificationPointNet
A model class instance (class not shown)
model = ClassificationPointNet(10,0.3,3)
torch.save(model.state_dict(), ‘/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/Lidarmnist/PointMNISTDataset/processed/training.pth’)
#torch.save(model, ‘/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/Lidarmnist/PointMNISTDataset/processed/training.pth’)
Load the weights from a file (.pth usually)
state_dict = torch.load(’/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/Lidarmnist/PointMNISTDataset/processed/training.pth’)
Load the weights now into a model net architecture defined by our class
model.load_state_dict(state_dict)
Create the right input shape (e.g. for an image)
dummy_input = torch.randn(64,1,3)
torch.onnx.export(model, dummy_input, “onnx_model_name.onnx”)
I get the following error while running the code:
File "Conversion_ONNX.py", line 32, in <module>
    torch.onnx.export(model, dummy_input, "onnx_model_name.onnx")
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/onnx/__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 111, in export
    _retain_param_name=_retain_param_name)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 313, in _export
    _retain_param_name)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 237, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/onnx/utils.py", line 204, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/jit/__init__.py", line 219, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace, return_inputs)(*args, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/jit/__init__.py", line 276, in forward
    out = self.inner(*trace_inputs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self._slow_forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 479, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/model/pointnet.py", line 113, in forward
    x, feature_transform = self.base_pointnet(x)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self._slow_forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 479, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/model/pointnet.py", line 70, in forward
    input_transform = self.input_transform(x)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self._slow_forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 479, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/vijay/Documents/Vijay/Lidar/pytorch_pointnet/model/pointnet.py", line 33, in forward
    x = nn.MaxPool1d(num_points)(x)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self._slow_forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 479, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/modules/pooling.py", line 77, in forward
    self.return_indices)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/_jit_internal.py", line 133, in fn
    return if_false(*args, **kwargs)
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 461, in _max_pool1d
    input, kernel_size, stride, padding, dilation, ceil_mode)[0]
  File "/home/vijay/anaconda3/lib/python3.7/site-packages/torch/nn/functional.py", line 453, in max_pool1d_with_indices
    input, kernel_size, stride, padding, dilation, ceil_mode)
TypeError: max_pool1d_with_indices(): argument 'kernel_size' (position 2) must be tuple of ints, not Tensor


Please assist me in solving this issue.
Best Regards,
Vijay