Hi there,
My goal is simply to load a .pt
model saved in Python into a nn::Module
in libtorch. Is this impossible to do programmatically?
I work on a libtorch-based application in which I can load HDF5 models from Keras. Since the HDF5 contains both the network graph (as a json string) and the weights, I can programmatically construct the nn::Module
and populate its trainable parameters. All without going through any format conversion! And, ironically, I cannot do the same with a model saved from Pytorch itself in python?
Am I correct in concluding that I must use jit::script::Module
instead for that task, and that there’s no conversion between that and nn::Module
? Can any Pytorch dev explain why not go the much easier route used by Keras to save/load models, toss jit::script
altogether and keep only nn
?
@ptrblck , @glaringlee , @tom , @yf225 : please help out here! I’ve struggled with this issue for months, and any pointer will be greatly appreciated. Thanks!