Closed ardeal closed 7 years ago
Hi,
You can change it to boost::serialization if you want (the syntax is nearly identical to cereal), or whatever manual load/save routine you'd like.
Hi Patrikhuber,
I don't like boost as well. I want to manually load/save it, but I don't know what should be loaded/saved. Do you have any example code or detailed solution?
Just look at the code of the detection_model class and its serialize() function to see which members are saved.
Yes, I read the code today.
using model_type = superviseddescent::SupervisedDescentOptimiser<superviseddescent::LinearRegressor<superviseddescent::VerbosePartialPivLUSolver>, InterEyeDistanceNormalisation>;
template<class Archive>
void serialize(Archive& archive)
{
archive(optimised_model, mean, landmark_ids, hog_params, right_eye_ids, left_eye_ids);
};
My problem is optimised_model is a template class. what will be saved in this class?
Well you posted it by yourself, using model_type = ...
.
using model_type = superviseddescent::SupervisedDescentOptimiser<superviseddescent::LinearRegressor
Yes. That's in fact the power of a serialisation library. But in essence it's mainly just a bunch of regressor matrices and parameters.
I got it! Thanks!
One more question to confirm my understanding:
all the data in all the serialize funcitons in all the upper template class should be saved/loaded. No other data needs to be saved/loaded, right? I am afraid I might miss something, and I migth not able to run the test funciton corrrectly.
I think that should be correct yes - everything in all required serialize() functions.
Thanks Patrikhuber!
Hi patrikhuber,
I noticed that you used C++11 lib cereal to serialize the trained model and save it to binary file. you use the following code to save the model: void save_detection_model(detection_model model, std::string filename) { std::ofstream file(filename, std::ios::binary); cereal::BinaryOutputArchive output_archive(file); output_archive(model); };
My question is: do you have any other substitute solution that doesn't use C++11 syntax about how to save/load the model to/from files? can you share non-C++11 code about how to save/load the model?