[mlpack-git] [mlpack] ANN Saving the network and reloading (#531)

Ryan Curtin notifications at github.com
Tue Mar 1 10:05:01 EST 2016


For what it's worth, this problem is encountered with other mlpack algorithms: sometimes the user wants to do, e.g., nearest neighbor search and save the model, but they can use different types of trees, and the trees are template parameters.

What I've done in those situations is to create a "wrapper" class that serializes an identifier saying what type is being used, then serializing the appropriate type.  Take a look here:

https://github.com/mlpack/mlpack/blob/master/src/mlpack/methods/neighbor_search/ns_model_impl.hpp#L52

For the situation of an arbitrary neural network architecture, the problem is a lot harder: you need some way to serialize the type information, and then some way to assemble an arbitrary type and return it when deserializing.  I think it will be a tricky (but fun) problem to solve... :)

The approach I've taken, in general, towards serializing arbitrary types is this: "if using an mlpack command-line program, the type should be handled for the user; if using the mlpack C++ code, then the user is responsible for serializing and deserializing the correct type".  So if the user uses the `mlpack_allknn` program, then the `NSModel` class is transparently used to serialize the correct type.  If the user is writing C++, then they can use the `NSModel` class if they want, but whatever they choose to do, they will have to remember to deserialize their model into the correct type.

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/531#issuecomment-190758563
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160301/3e6aa1d5/attachment.html>


More information about the mlpack-git mailing list