参考pytorch。 背景 希望使用勒让德多项式拟合一个周期内的正弦函数。 真值: y = s i n ( x ) , x ∈ [ − π , π ] y=sin(x),x\in\left[-\pi,\pi\right] y=sin(x),x∈[−π,π] torch::Tensor x = torch::linspace(-M_PI, M_PI, 2000, torch::kFloat);
文章目录 安装模型转换测试测试环境Makefilemain.cpp测试what(): PyTorch is not linked with support for cuda devicesconversion to non-scalar type torch::jit::load("model.pt")cannot open shared object file: No such file
原因是你训练用的pytorch 可能是 1.2 ,后来运行测试在libtorch 上,libtorch 太新了 terminate called after throwing an instance of 'std::runtime_error'what(): The following operation failed in the TorchScript interpreter.Trac