Ask questionsa retrained and saved jit module could not be reload.

I'm try to retain a JIT module from pytorch using c++ based on Libtorch libtorch-win-shared-with-deps-1.3.0 _cpu, and save retrained module for next usage. the save and reload process will be like the following , but get erro while try reload.

		torch::serialize::OutputArchive output_archive;
		auto presavedModule = torch::jit::load("D:/localshare/data/model/");"D:/localshare/data/model/");
		auto savedModule = torch::jit::load("D:/localshare/data/model/");
		savedModule.dump(true, true, true);

reported error:

expected newline but found 'number' here:
at code/__torch__/
import __torch__.modelv2.features.16.conv.1
import __torch__.modelv2.features.17
import __torch__.modelv2.features.17.conv
import __torch__.modelv2.features.17.conv.0
import __torch__.modelv2.features.17.conv.1
import __torch__.modelv2.features.18
class features(Module):
  __parameters__ = []
  __annotations__ = []
  __annotations__["0"] = __torch__.modelv2.features.0
                                                   ~~ <--- HERE
  __annotations__["1"] = __torch__.modelv2.features.1
  __annotations__["2"] = __torch__.modelv2.features.2
  __annotations__["3"] = __torch__.modelv2.features.3
  __annotations__["4"] = __torch__.modelv2.features.4
  __annotations__["5"] = __torch__.modelv2.features.5
  __annotations__["6"] = __torch__.modelv2.features.6
  __annotations__["7"] = __torch__.modelv2.features.7
  __annotations__["8"] = __torch__.modelv2.features.8
  __annotations__["9"] = __torch__.modelv2.features.9
Compiled from code
Type class std::runtime_error

Is there any sugesstion:

cc @ezyang @gchanan @zou3519 @jerryzh168 @suo


Answer questions driazati

Are you able to share the you are using to get this error?


Related questions

TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above hot 3
AttributeError: module 'torch.jit' has no attribute 'unused' hot 3
Script freezes with no output when using DistributedDataParallel hot 2
Adding Pixel Unshuffle hot 2
DataLoader leaking Semaphores. hot 2
[feature request] Add matrix exponential hot 2
cublas runtime error on torch.bmm() with CUDA10 and RTX2080Ti hot 2
libtorch does not initialize OpenMP/MKL by default hot 2
Use torch.device() with torch.load(..., map_location=torch.device()) hot 2
Cuda required when loading a TorchScript with map_location='cpu' hot 2
PyTorch 1.5 failed to import c:miniconda3-x64envs estlibsite-packages orchlibcaffe2_nvrtc.dll - pytorch hot 2
Error during import torch, NameError: name &#39;_C&#39; is not defined - pytorch hot 2
Quantisation of object detection models. hot 2
Problems with install python from source hot 2
torch.utils.tensorboard.SummaryWriter.add_graph do not support non-tensor inputs - pytorch hot 2
Github User Rank List