hughperkins / DeepCL

OpenCL library to train deep convolutional neural networks
Mozilla Public License 2.0
866 stars 200 forks source link

Supervised Classification Example #39

Closed skn123 closed 8 years ago

skn123 commented 8 years ago

Is there any example for supervised classification of feature vectors? Can you please share some pointers?

hughperkins commented 8 years ago

Yes sure, so:

What language are you hoping to use to run the training? ie, python? C/C++? commandline? (something else?)

skn123 commented 8 years ago

Hugh Thanks for the response. I work with C++. So I started off with looking at train.cpp / test.cpp from command line. So an ideal example for the "uninitiated" would be as follows: a.) A simple example of populating a set of Multi-class training feature vectors in DeepCL's internal format b.) Generating a training model c.) Serializing the model to a std::string and saving it to disk d.) Loading the model from disk as a std::string and deserializing it e.) Classify or regress a set of test features using this model.

Do you have any example to this effect?

hughperkins commented 8 years ago

Somehow this fell through my radar. I should address this...

skn123 commented 8 years ago

Hugh, any updates on this?

hughperkins commented 8 years ago

Well, lets go one step at a time, otherwise I just stare at a huge long list, and go ..' errr .... some time, maybe' :-P

So, 'a.) A simple example of populating a set of Multi-class training feature vectors in DeepCL's internal format'. A few places you can get this from:

So, pick one of these loaders, and look how it works. Alternatively, basically there are two sets of data:

hughperkins commented 8 years ago

alternatively, really, skip all the file links, and just jump to the last couple of sentences. You need two 1-dimensional arrays, as stated above:

hughperkins commented 8 years ago

(really, everything you need is in https://github.com/hughperkins/DeepCL/blob/master/src/main/train.cpp , its just a question of picking out the bits you need really. for example, this handles a bunch of different trainers https://github.com/hughperkins/DeepCL/blob/master/src/main/train.cpp#L287-L319 but you only need to pick one. For example, if you want to use SGD, then use these lines https://github.com/hughperkins/DeepCL/blob/master/src/main/train.cpp#L289-L293 )

hughperkins commented 8 years ago

as far as 'serializing to a string', this would be new functionality. you can save to disk, but it would be in binary format. It's handled by this line https://github.com/hughperkins/DeepCL/blob/master/src/main/train.cpp#L417-L418 , so you can follow the breadcrumbs, and have a look at how it works. If you want to convert to a string, you could for example copy and paste the WeightsPersister, to a new class, and modify it to your requirements.

hughperkins commented 8 years ago

As far as 'classify', you can look at how the 'predict' works, ie https://github.com/hughperkins/DeepCL/blob/master/src/main/predict.cpp Again, you'll need to kind of pick out the bits you need, and throw the rest away. For example everything after line 287 https://github.com/hughperkins/DeepCL/blob/master/src/main/predict.cpp#L287 is just about reading commandline options, printing usage etc, so you can probalby just ignore that. Otherwise, we can see we: