Skip to content

export model to Torch Script #959

Closed Answered by BenjaminBossan
fouvy asked this question in Q&A
Discussion options

You must be logged in to vote

In general, the PyTorch Module is available as an attribute called module_ on the skorch net. So e.g.:

net = NeuralNet(MyModule, ...)  # MyModule is your custom or pretrained pt module
net.fit(X, y)
module = net.module_  # this is the trained MyModule instance
traced_module = torch.jit.trace(module, ...)

It is not possible to trace the net itself, only the PyTorch Module.

I haven't worked with torch script, so if the provided solution not work, please report back.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fouvy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #958 on April 26, 2023 09:25.