[mlpack-git] [mlpack] improve speed of SparseAutoencoder and make it more flexible (#451)

stereomatchingkiss notifications at github.com
Thu Oct 22 20:13:34 EDT 2015


Another problem of making the layers templatize is how could the users modify the value of the layers?
I would like to allow the users pass in the layers by constructor.

    SparseAutoencoder(const arma::mat& data,
                      size_t visibleSize,
                      size_t hiddenSize,
                      double lambda = 0.0001,
                      double beta = 3,
                      double rho = 0.01,
                      HiddenLayer &&hiddenLayer = HiddenLayer(),
                      OutputLayer &&outputLayer = OutputLayer());

This api do not looks good since there are too many parameters, it reminds me of legacy c codes or c with classes. Another constructor maybe a better choice

     SparseAutoencoder(const arma::mat& data,
                       size_t visibleSize,
                       size_t hiddenSize,
                       HiddenLayer &&hiddenLayer = HiddenLayer(),
                       OutputLayer &&outputLayer = OutputLayer());

I use && because some layer maybe expensive to copy, this way the users can only pass in the HiddenLayer and OutputLayer by rvalue, then the constructor will be able to move them. Let the SparseAutoencoder keep the layers could make codes easier to deal with(the users do not need to create another variables to keep the layers alive, let SparseAutoencoder handle them).

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/451#issuecomment-150392565
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20151022/8d5e9032/attachment.html>


More information about the mlpack-git mailing list