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
CLI for ANN #1254
Comments
You are right there doesn't exist an CLI for the ANN classes. You would have to use it from within your C++ code. I think it would be great to have an executable for the network code, however since there is no single architecture it's somewhat complex to provide all the necessary settings and at the same time make it easy to be used. |
I am not proficient with C++. I was hoping to add a Ruby wrapper to the CLI. So two things,
|
For more information about how to add bindings to other languages please take a look at: http://www.mlpack.org/docs/mlpack-git/doxygen/bindings.html, let us know if we should clarify anything. |
Hi Arjun, There isn't currently any planned support for Ruby. If you are interested in writing a Ruby binding generator, it would be great and @zoq has given a link to some useful documentation. But unfortunately proficiency with C++ is going to be necessary to write this binding generator, so you may want to also study C++ a little more closely before diving too deep. |
Hi rcurtin, I was planning to work on this in small pieces. Could I first implement a CLI that achieves this - |
We need to wait for @zoq's input also, but my opinion is that any CLI program needs the following functionality:
So writing something for a digit recognizer might be a good warmup exercise, but anything that we merge into mlpack should at least have the requirements above, in my opinion. |
@zoq, since we don't have any CLI for ANN classes, do you think it will be a good idea to start with a CLI for fully connected ANN of required configuration with options for all other required parameters? |
@rcurtin : |
I agree with @rcurtin, we should not merge anything that doesn't support:
YAML for the config file sounds like a good idea to me, however parsing isn't as simple as e.g. csv and I don't like to include another dependency (perhaps boost spirit could be helpful).
Instead of specifying the architecture e.g. layers via command line parameters we use a config file, YAML is just the format, we could also use JSON or XML.
If you have something in mind, we are open for suggestions.
The LeakyReLU layer doesn't follow the same interface as e.g. the TanH since it holds an extra parameter |
Agreed, I want to avoid new dependencies also. It's also possible we could come up with a very simple custom format that we can parse ourselves. I do think boost::spirit could be used to parse YAML but it looks like implementing a YAML parser might be complex: https://github.com/cierelabs/yaml_spirit So maybe some plain text file is best?
could be one way to do it for a 3-layer linear network with 50 hidden neurons in each hidden layer and 10 output neurons. I don't have much of a preference; personally I think we could do just about anything here and as long as it is well documented and simple enough then nobody will have a problem with it. |
Agreed, that's super simple and easy to read. |
I really like this idea. Also, I have worked with neural networks before and would love to write a CLI for it. |
@desai-aditya Do you want to work on this as well? Because you did comment on this first. |
Yes we can surely collaborate @akhandait . How do you suggest we split the work? |
Okay, so I think we will need a day or two just to get really comfortable with the ANN method. The next step according to me will be to come with a concrete model for how we will implement it. If you have already dived into it and are comfortable maybe you could look at the CLI bindings we already have and come up with a basic structure for our implementation. |
This all sounds good to me. Probably we will have to flesh out the file configuration format somewhat, but if we can keep it of the form
I think that would be simplest to parse and work with. Sometimes the input or output size may not be needed. It'll also be really important to document exactly what the format is so that people can assemble simple networks just by looking at the documentation. |
Yes, |
so help me if I forgot something - and the following in network.conf file is this fine? @zoq, @rcurtin ,@akhandait |
Looks good to me, and I agree let's start with the linear models. About the network.conf file, ideally we interpret everything after the layer name as parameter, like for the linear layer this is input and output size, but for the convolution layer, there are more parameter we could set. We could easily split this up into two parts: writing the parser and writing the cli. The cli could just pretend the parser already works and work with some artificial settings. |
@akhandait , @zoq, @rcurtin - I think the parser will parse the file and return the values to the main CLI program. The values will then be used to make the model and train the dataset inside the CLI . There are some parameters that will be used in general that will be needed as arguments to the CLI. The parser should only parse the values and not compile the model. It could be that the user supplies the model too. This is what I understand. I have already started working on the CLI . @akhandait You can go ahead with the parser and join me as soon as you finish it. |
@desai-aditya Can you please have a look at the CLIs we already have. You can find them here:
|
@akhandait Don't worry I have already taken a look at how CLI's work and experimented with them. |
@desai-aditya is right, the parser will just parse the file that defines the structure and the CLI will build the model and run the model. So let's say we follow @rcurtin's idea of
the cli builds the network based on the provided information:
and performs the requested action. I hope this makes sense, let me know if I should clarify anything. A good starting point for the parser is: https://github.com/mlpack/mlpack/blob/master/src/mlpack/core/data/load_csv.hpp |
@desai-aditya it's good you have already started with the CLI program, I have my exams over the next week, I will still try to take as much time out as I can and work on the parser, I am also working on another issue, so I won't claim too many tasks as it will just delay necessary tasks. |
@akhandait don't worry, and best of luck with your exams. |
Hi @desai-aditya @akhandait , are you still working on this? If yes, is there any way I could help? |
Hi @Namrata96. Yeah, I have been a little slow with regard to this issue but am working on it. I think I will open a WIP pull request in coming days and maybe you can help me by reviewing it extensively. |
@akhandait @zoq I am extremely sorry for delay in replying. I had my exams in the past week. I am free now and will be continuing back on the CLI. |
@rcurtin you are right, YAML is more user-friendly but I have just finished the JSON implementation with a boost property tree storing it and categorising the information into a number of maps storing the data in a dictionary like format. It am all for YAML but I currently want to focus on making the whole thing work; I shall provide YAML support (not much code though) after the main part is done. What do you say?
I have tried following the format of the original documentation, but there are some exceptions (for better readability), for example the linear layer has the original documentation:
You'll be glad to hear, that part is already done (the code, not the doc part though) and I have done it exactly as you have mentioned here. I am structuring it in such a way that bindings and other stuff would be much easier to add. Actually I am learning a lot (A lot actually!!) while building this CLI. One more thing, regarding the documentation are we planning to participate in Google's newly announced Season of Docs this year? |
That's fine with me. 👍
Ah, what I was suggesting here is automatically generating the documentation for each layer, as opposed to manually writing it. It may be complex to come up with a good solution for that.
Great! If there is any part of the code I can explain, just let me know. There are a lot of complex pieces that fit together in complex ways. :)
Not sure, I think there is some interest in it in the community, so we'll see. 👍 I think it is a cool program, the issue for me at least is always time. (That said I don't have to run the effort, so if there's critical mass to do it, I think we should!) :) |
Thanks. I shall let you know if I need any further clarification anywhere. |
Critical comments on it:
I will update this if something else comes to my mind. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! 👍 |
I would like to work on this issue. Can I take this issue? |
This would be a useful addition. A CLI is already part of Neural Network Libraries Is anybody still working on this? |
Hey, I was recently looking at this issue. After reading the discussion here, I figured out that we need to do two things here -
In my opinion, a simple text file would not suffice, because it is easier to think of the model in a structured way (json/xml) Then, key question is "How do we parse that structured config file?" @sreenikSS has almost completed the parser in #1837 , but it is done using So, to test it out, I created a small model and saved it in the following way. data::Save("model.json", "model", model, false); The model.json generated looks like this. This looks pretty bad because this actually saves all the parameters and everything associated to the model. To use cereal, the user actually needs to make a config file similar to it, This is practically not possible for user to write it. So, now we are back to the same question i.e. how do we parse config file.
So, I want to ask what should be a good way to approach this? Thanks. |
What I had in my mind was to have some sort of config class that we could serialize and use it as an intermediate format to construct the model. Isn't that what the parse would do as well? I would expect that a config class something like: class Config
{
public:
std::vector<struct{std::string name, inSize, outSize}> layerName;
} Would look easy enough. |
@RishabhGarg108 The following may be relevant: |
@bkmgit , thanks for these resources. I will definitely look at them. I have no experience with parsing and stuff. So currently, I am trying and exploring various things, like what @zoq mentioned about a |
@bkmgit , I looked at both of these. It turns out that both of these tools are for interoperability and optimization of trained models across different frameworks and devices for making inferences. This is not exactly what we are looking for. Infact, all we want is just a simple way to define the architecture for an ann model and then be able to translate that into a mlpack ann model. I hope that makes sense. |
We should leave this open---it is still important functionality we should add at some point. |
Hey
Are ANN classes available from the CLI? From the docs it isn't apparent.
How can we use it otherwise?
The text was updated successfully, but these errors were encountered: