1

I was trying to convert a LightGCN .pth file to a pb file, but I don't know how to convert it. I used the onnx lib, but I don't know the function of dummy_input, and am not sure that was correct.

import onnx
from onnx_tf.backend import prepare
from torch.autograd import Variable

trained_model = Recmodel  # Recmodel is LightGCN model
trained_model.load_state_dict(torch.load(weight_file))

# Export the trained model to ONNX
dummy_input = Variable(torch.randn(1, 1, 28, 28)) # one black and white 28 x 28 picture will be the input to the model
torch.onnx.export(trained_model, dummy_input, "output/gnn.onnx")

And also I got an error:

TypeError: LightGCN.forward() missing 1 required positional argument: 'items'

I referred to this.

InSync
  • 4,851
  • 4
  • 8
  • 30
Hwi
  • 11
  • 2

0 Answers0