Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANN No copy ctor for FNN #510

Closed
theSundayProgrammer opened this issue Jan 28, 2016 · 7 comments
Closed

ANN No copy ctor for FNN #510

theSundayProgrammer opened this issue Jan 28, 2016 · 7 comments

Comments

@theSundayProgrammer
Copy link
Contributor

I am trying to modify mlpack::ann::BuildVanillaNetwork to return FFN:
return FFN<decltype(modules), decltype(classOutputLayer), PerformanceFunctionType>(modules, classOutputLayer);
But compilation fails with:
... attempting to reference a deleted function.
Perhaps, one of the items in the tuple does not support copy construction.

@theSundayProgrammer
Copy link
Contributor Author

I implemented copy ctor. Hence the bug may be closed.

@rcurtin
Copy link
Member

rcurtin commented Jan 29, 2016

Want to file a pull request? Maybe we could incorporate your code.

@theSundayProgrammer
Copy link
Contributor Author

Sure! I'll let you know when I am ready.

@theSundayProgrammer
Copy link
Contributor Author

I ran into a circular reference while testing. To be more precise:
LinearLayer contains Optimizer which holds a reference to the container.
Hence simple copy will copy the reference even though the parent object has
changed.

On Fri, Jan 29, 2016 at 2:10 PM, Ryan Curtin notifications@github.com
wrote:

Want to file a pull request? Maybe we could incorporate your code.


Reply to this email directly or view it on GitHub
#510 (comment).

Joseph Chakravarti Mariadassou
http://thesundayprogrammer.com

@stereomatchingkiss
Copy link
Contributor

I added move constructor and move assignment on most of the layers in the pull request of #451.
I also change the reference of the output layer of FFN to non-reference type, it would be very easy to implement move constructor and move assignment for the FFN after #451 is merged. Maybe you can copy the codes of the #451 before it is merged, and implement the move assignment and move constructor.

@theSundayProgrammer
Copy link
Contributor Author

I made the following changes:
(a) removed circular reference in optimizer as in
LinearLayer::LinearLayer: optimizer(*this)
to
`LinearLayer::LinearLayer: optimizer()'

(b) removed Law of Demeter violations as in
t.Optimizer().Reset() to
t.ResetOptimizer()

t.Optimizer().Update() to
t.UpdateOptimizer()

t.Optimizer().Optimize(); to
t.OPtimize()

(c) change optimizer from pointer to shared pointer (TODO: make Optimizer a
member variable)

(d) removed destructors and copy constructors to allow compiler to generate defaults. As there are no raw pointers there is no need for destructor.

(e) Added a few unit tests for copy ctor

(f) All the unit tests except for a couple unrelated to ANN ran to success

The result is in https://github.com/theSundayProgrammer/mlpack

@rcurtin
Copy link
Member

rcurtin commented Feb 8, 2016

Sorry for the slow response, I didn't really have a chance to look into this until today. If you'd like to open a PR, that might be a good idea. A couple quick notes:

If you open a PR, we can discuss in more detail and probably get @zoq's opinion, which will be the important opinion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants