我有一个在matlab中创建的文件。我用得很好 python加载:
import cntk as C
z = C.Function.load("Net.onnx", format=C.ModelFormat.ONNX)
在c ++中,我有异常Selected CPU as the process wide default device.
关于引发异常:
'Gemm:形状无效,输入A和B预期为rank = 2 矩阵
我使用了导入的nuget:CNTK.CPUOnly CNTK.Deps.MKL CNTK.Deps.OpenCV.Zip
#include <stdio.h>
#include "CNTKLibrary.h"
void main(){
std::wstring modelFile(L"Net.onnx");
//line crash
CNTK::FunctionPtr modelFunc = CNTK::Function::Load(modelFile, CNTK::DeviceDescriptor::CPUDevice(), CNTK::ModelFormat::ONNX);
}
答案 0 :(得分:0)
最后我提出了其他解决方案,我保存在python中以模拟cntk,而不是从c ++加载它 cntk格式(原始模型从matlab长时间导出到onnx)
python代码
import cntk as C
z = C.Function.load("Net.onnx", format=C.ModelFormat.ONNX)
z.save(os.path.join("folder", "net" + ".dnn"))
c ++加载
#include "CNTKLibrary.h"
std::wstring modelFile(L"net.dnn");
CNTK::FunctionPtr modelFunc = CNTK::Function::Load(modelFile, CNTK::DeviceDescriptor::CPUDevice());