[mlpack-git] [mlpack] Serialization of ann (#513)

stereomatchingkiss notifications at github.com
Sun Jan 31 23:00:33 EST 2016


According to the [answer of stackoverflow](http://stackoverflow.com/questions/5058349/is-it-safe-to-use-the-this-pointer-in-an-initialization-list), it should be safe to that as long as we do not access the member haven't construct yet(including virtual member function, but mlpack do not use any virtual, so I think this would not be an issue). 

What I mean is, change the reference to pointer as following

```
RMSPROP(DecomposableFunctionType* function,
          const double lr = 0.01,
          const double alpha = 0.99,
          const double eps = 1e-8) :
      function(function),
      lr(lr),
      alpha(alpha),
      eps(eps)
```

So we could construct it as 

```
SparseBiasLayer(const size_t outSize,
                  const size_t batchSize,
                  WeightInitRule weightInitRule = WeightInitRule()) :
      outSize(outSize),
      batchSize(batchSize),
      optimizer(new OptimizerType<SparseBiasLayer<OptimizerType,
                                                  WeightInitRule,
                                                  InputDataType,
                                                  OutputDataType>,
                                                  InputDataType>(this)),
      ownsOptimizer(true)


```
Is this the problem you are worrying about?Or we are talking different problems?

ps : I forgot I open the same issue on #495, rcurtin has an [example](https://github.com/mlpack/mlpack/commit/60c81702c432014544351948c091d03deeef6985). If you think  it is ok, I would find a way to serialize it.

---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/513#issuecomment-177752093
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160131/88e190e6/attachment.html>


More information about the mlpack-git mailing list