- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new to DAAL, having a mixture of success, failure and mystery.
I want to build an SVM model and write that model to disk. Then subsequent tasks can read that model and use it for scoring.
Start with the example file svm_two_class_csr_batch.cpp which I have altered as shown below
/* Retrieve the algorithm results */
trainingResult = algorithm.getResult();
data_management::InputDataArchive *archive = new data_management::InputDataArchive();
trainingResult->serializeImpl(archive);
const size_t nbytes = archive->getSizeOfArchive();
byte * buffer = new byte[nbytes];
archive->copyArchiveToArray(buffer, nbytes); // I would now write this to disk, seems to work...
services::SharedPtr<svm::training::Result> m2; // then I would read it back in order to create a copy of trainingResult (m2)
OutputDataArchive dataArch(buffer, nbytes);
m2->deserializeImpl(&dataArch);
But this always dies on that last statement, core dump from deep within DAAL.
What am I doing wrong? Again, my objective is to build a model once, persist it to disk, then have multiple other tasks be able to read that model and use it for scoring.
Sorry if this is a dumb question, I am very new to DAAL
Thanks
Ian
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ian,
There are two things you should change in this example:
- use serialize() function instead of serializeImpl and deserialize() instead of deserializeImpl
- create an empty result object before deserialization: services::SharedPtr<svm::training::Result> m2(new svm::training::Result() )
You can look at serialization example for more details here: examples\cpp\source\serialization\serialization.cpp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Ilya
works like a charm. I can now write the model to disk, then read it back later, score a test set and get the same results, exactly what I wanted.
Thank you.
Ian
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page