Closed nuaawzl closed 6 years ago
Thank you:) Do you want to load the parameters in C++? I think you can try the function
static void Load(const std::string &file_name,
std::vector<NDArray> *array_list = nullptr,
std::map<std::string, NDArray> *array_map = nullptr);
or
MXNET_DLL int MXNDArrayLoad(const char* fname,
mx_uint *out_size,
NDArrayHandle** out_arr,
mx_uint *out_name_size,
const char*** out_names);
in $MXNET_HOME/cpp-package/include/mxnet-cpp/ndarray.h and $MXNET_HOME/include/mxnet/c_api.h.
And there are some examples to use the functions.(https://github.com/apache/incubator-mxnet/blob/master/cpp-package/example/feature_extract/feature_extract.cpp
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/ndarray/utils.py)
Thanks, I want to load the symbol and parameters in C++. But the model use a custom operator. MXNet C++ has no the operator, so I can't load the json file.
@nuaawzl I found MXSymbolCreateFromFile is used to load all symbols, including Custom Operator. And the custom operator is registered in python/mxnet/operator.py.
I think it may be a solution.
Thank you very much. I coded the new operator and recompiled mxnet. I'll try your advice.
Hello, it's very useful! I have a problem, I define a custom operator in mxnet(python) and get a model. Now I want to load the model(.json & .params ) by mxnet(C++). Can you give me some advice? thanks.