-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add callback to monitor the training process #55
Conversation
@zoq Would you think that it is better to have some program options in this example, just to allow the users to pass the path of the model dynamically instead of compiling the model each time. It seems that model zoo requires boost program options as a dependency. If it is the case, I can use it to so that, or I can do it old fashin (argc, argv) function? |
I think that is a great idea, I guess, we can also use mlpack's CLI functionality for the same. I guess that would bring us one step closer to expose those models to other languages as well (bindings for python, julia, etc.). |
Great, I will push as soon as possible with mlpack's CLI |
@shrit, will you be pursing the same for LSTM or do you mind if I take that up? |
I am going to finish only the Kaggle models. You can start working on LSTM |
Great, I hope to open a PR soon. |
@zoq I think there is something missing with the actual CMake. Since I have added the mlpack:CLI It was not possible to link with boost program option, (my version is 1.71.0). CMake was able to find the boost headers, but not the implementations. |
Ahhh, sorry to be a little late to the party here and reply after a lot of the code has already been done. At least my understanding of the I guess, what I mean is, the use of the CLI class here does mean that we can nicely compile into a program that can do digit recognition with various parameters. But I think that more people are using this as a simple example, moreso than actually doing digit recognition with it. I think that it would be better to have a "generic" binding in the main mlpack repository that can work with neural networks of arbitrary shape and size (defined in a text file or something). There's an issue open for that: mlpack/mlpack#1254. Then, the models repository can primarily be a set of minimal-code examples that people can adapt into their own work. |
@rcurtin I understand.
Finally, if the converter is ready, we will have only to add mlpack::CLI and write the |
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.
Ok, I took a look through the code; thanks for making these changes, I think they make the example a lot more understandable. 👍 I left out any comments on the input parsing for now until we get through #61 and figure out what to do. In any case, whatever we decide, it should be pretty easy to adapt that for here.
I'm not sure of the status of mlpack/mlpack#1837 or the model converter repository; perhaps @sreenikSS can add a bit more. What I do know is that I am excited about that effort. :)
<< std::endl; | ||
} | ||
|
||
int main(int argc, char* argv[]) |
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 for going through and changing from the CLI framework; I hope it wasn't too much effort. Let's see where the discussion on #61 goes and I think that will clarify what the best option is here. So for now I won't add any comments there. :)
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 agree, let us wait for the discussion in mlpack/models#61 to see what to do with argc, argv
You do not have to worry about it, It was not much effort to do remove all the CLI code.
|
||
using namespace mlpack; |
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.
Hmm, removing this seems to make the later code a bit more verbose with the mlpack::
namespacing bits. Would it be good to leave using namespace mlpack;
in, or did I overlook the reason for removing it? :)
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.
In fact, I do not know mlpack convention for namespaces. If you would like I will keep all of them. However, I would not use any using namespace
in his case since there are several libraries, Actually, when I started copying the code as a simple user, I had a problem knowing to which library each function belongs, especially there are the Kaggles functions that do not belong to any namespace.
For example, I would only keep namespace if we were using only mlpack. What do you think?
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.
@rcurtin Tell me what do you think about namespaces
. I would remove all of them if it is fine. What do you think?
using namespace mlpack::ann; | ||
|
||
using namespace arma; | ||
using namespace std; |
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'd also be okay with it if you wanted to leave this in. It would at least make the std::cout
calls a few characters shorter. :)
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.
Same as before, even I would declare a namespace for these helpers https://github.com/mlpack/models/blob/master/Kaggle/kaggle_utils.hpp if we decide to keep them. In this file it defines a save
function, which can be ambiguous, since there are mlpack::data::save
and arma::save
@rcurtin I will remove |
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.
Awesome, thanks @shrit for continuing to work on this. I think it's basically ready. Do you want to open another version in the new models/
repository that can turn these into bindings? (No hurry of course.)
@rcurtin Yes I going to open a new pull request for models with all the |
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
@rcurtin I think you can merge this one 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.
Agreed, we can go ahead and merge it. I have one comment left, so if you want to handle that before merge, that would be great; otherwise, I can open an issue for it. 👍
mnist_simple/mnist_simple.cpp
Outdated
// As before, it's necessary to get rid of header. | ||
// should be sent to kaggle website). | ||
arma::mat testingDataset; | ||
mlpack::data::Load("../Kaggle/data/test.csv", testingDataset, true); |
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.
What should we do about the data? Now it's in ../data/kaggle_train_test_dataset.zip
. I guess we could assume that the user has unpacked the zip in that directory? (Or maybe we provide a quick script to unpack all the data or something?)
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 prefer removing the entire data directory and provide a small script that downloads the necessary data for each example. We do not have to keep data tracked by git. This will increase the size of the git repository for no obvious reason.
In addition, we might use bigger datasets in the future, which can not be added to this repository.
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.
Sounds good, that works for me. Do you want to open an issue pointing out that we should add a script to download any datasets?
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 will handle the issue with a pull request directly.
I will try to found the sources for the dataset and download them using wget or curl.
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.
Second approval provided automatically after 24 hours. 👍
mnist_cnn/mnist_cnn.cpp
Outdated
model.Predict(validX, predOut); | ||
// Calculate accuracy on validating data points. | ||
predLabels = getLabels(predOut); | ||
double validAccuracy = arma::accu(predLabels == validY) / validY.n_elem; |
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.
Hey @shrit, I think this might not be correct. As They will never will be exactly equal. Do you mind running some test on this. Thanks a lot.
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 think I am wrong here, they are labels so they should be correct. However when I tried them I got an accuracy of 0 and with existing function I got an accuracy of 96%. Maybe I did something wrong.
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.
@kartikdutt18 You are right, I missed this file, I need to remove getLabels
functions as I have removed the kaggle_utils.hpp
file. I rebased and I did not build locally.
I was working on a set of makefiles for all examples. The problem is that if we use only Makefiles
instead of CMake, we will lose support for Visual Studio
what do you think @rcurtin @kartikdutt18
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.
@kartikdutt18 the code here looks right to me, but casting can make a difference here---size_t
divided by size_t
will be 0 in this case, but if one of the types is double
(or if the result type is double
?) then I think it will work fine. If the current code gives good accuracy numbers then I think it's fine. Also, I realized, we should multiply trainAccuracy
and validAccuracy
by 100. :)
@shrit good point about Visual Studio. The real complexity of build systems like CMake is just in getting all the dependencies right and everything. The basic Makefile we'd provide would just assume that everything was available on the system, so even that is not "bulletproof"---the user will still have to make sure that their system is set up right. For Visual Studio, I think that if the user sets up a new project correctly (like in the first part of https://www.mlpack.org/doc/mlpack-3.2.2/doxygen/sample_ml_app.html), then they can copy-paste this code directly and it should work.
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.
Also we will be adding notebooks so users can use that and we can instructions for gcc etc. So maybe that isn't an issue. Not sure though.
Signed-off-by: Omar Shrit <shrit@lri.fr>
Signed-off-by: Omar Shrit <shrit@lri.fr>
This function is required to convert from classification probability into labels Signed-off-by: Omar Shrit <shrit@lri.fr>
@shrit @kartikdutt18 let me know when you guys are good with merging this, and I'm happy to hit the button. :) |
Just one last thing, If an @shrit could add some results in comments about accuracy, I am good to go as well. |
@kartikdutt18 Agreed, I will try to test this before tomorrow. (I will multipliy by 100 for accuracy). |
Great. Thanks a lot. |
Signed-off-by: Omar Shrit <shrit@lri.fr>
@kartikdutt18 This is part of the output related to
|
Yes, but your example uses the old functions from |
I think I also used ensmallen callbacks. But yes I used Kaggle_utils functions. |
@shrit maybe you need to cast |
Signed-off-by: Omar Shrit <shrit@lri.fr>
@rcurtin, Yeap, it was related to double casting, I think we can hit the magic button now.
|
Awesome. Magic button pressed. :) |
Signed-off-by: Omar Shrit shrit@lri.fr