-
Notifications
You must be signed in to change notification settings - Fork 3
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
Created a minibatch iterator selection function #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, and don't forget to add some tests!
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
I will re-factor the code and also add the tests now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @farhadrclass, i suggested some minor changes!
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
@paraynaud for some reason the doc builder fails we have to option |
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the documentation of the new methods.
I made some changes to ease the understanding.
If you agree with the new doc, we will ask Dominique to finally review the PR.
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
Co-authored-by: Paul Raynaud <paul.raynaud66@hotmail.fr>
@dpo, this one should be ready to go. |
src/KnetNLPModels.jl
Outdated
@@ -99,6 +103,8 @@ function KnetNLPModel( | |||
x0, | |||
layers_g, | |||
nested_array, | |||
1, #inti the batch current i to 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the comment. Index of the first minibatch? Normally, you don't index iterators. You just loop through them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but this is because Knet doesn't use the iterator correctly
The way knet does it is to ignore the size and do {i \in [1,data_size-batch_size]} which is terrible but that mean i for batch size of 1000 in MNIST is between 1 to 59999 which is weird for me but that is how it was written (I spent 2 days debugging till I find this weird behavior )
check here the knet random code: https://github.com/denizyuret/Knet.jl/blob/e9bec84b826ee7231db4ca8772fae6eb2fd4bcb9/src/train20/data.jl
function rand(d::Data)
i = rand(0:(d.length-d.batchsize))
return iterate(d, i)[1]
end
So basically their iterator is using i and i actually is the index of the data not the mini-batch,
I am open to suggestion how to fix this since I think the problem is Knet's iterator is to some extend weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "inti" be "init" ? Better write "initialize".
nlp.current_training_minibatch = rand(nlp.training_minibatch_iterator) | ||
function reset_minibatch_train!(nlp::AbstractKnetNLPModel) | ||
nlp.current_training_minibatch = first(nlp.training_minibatch_iterator) | ||
nlp.i_train = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we see that the index 1 is not useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use the index 1 as a flag for when data is visited or new iteration has started
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
no need for return 1 since our reset_minibatch_.. does reset them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a few minor comments. You can merge after that.
src/KnetNLPModels.jl
Outdated
@@ -99,6 +103,8 @@ function KnetNLPModel( | |||
x0, | |||
layers_g, | |||
nested_array, | |||
1, #inti the batch current i to 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "inti" be "init" ? Better write "initialize".
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
Co-authored-by: Dominique <dominique.orban@gmail.com>
as discussed here #52