-
Notifications
You must be signed in to change notification settings - Fork 561
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
Recurrent neural layers support (RNN, LSTM) via Caffe backend (Direct inputs to LSTM) #140
Comments
This is a good example to start working on and to reproduce: https://github.com/fchollet/keras/blob/master/examples/imdb_bidirectional_lstm.py |
Good link to get started with: http://christopher5106.github.io/deep/learning/2016/06/07/recurrent-neural-net-with-Caffe.html |
Hi @beniz , |
Sure @kyrs. I'd suggest as a first goal that you take the keras example and try to get similar results with DD. To do this, you may have to go through a few steps. First, you may want to write the required In other words onve you've got the This is easier to say than do of course, and the input format to Caffe for lstm may not fit exactly the existing DD code, but based on your experiments, we'll fix that up. Let me know how this sounds. |
hi @beniz. I was trying to implement Christopher Bourez's blog( http://christopher5106.github.io/deep/learning/2016/06/07/recurrent-neural-net-with-Caffe.html ) on implementation of LSTM using caffe. Whole tutorial is based upon https://github.com/christopher5106/last_caffe_with_stn . I guess, caffe has officially added LSTM code in their master branch. BVLC/caffe#4629 Do you think there is a need to integrate a new lib just for LSTM especially when caffe already provide such functionality. One more point I found literature about LSTM implementation in caffe a little incomplete. Do you have any resources to learn more about it ?? . This will be my first time coding with caffe |
finally managed to find some example ... https://github.com/jeffdonahue/caffe/tree/recurrent-rebase-cleanup/examples/coco_caption . |
|
hi @beniz , |
@kyrs OK thanks. Let me know if you need help, and reach out on gitter for instance. We can coordinate there. |
@beniz as per our discussion I have modified my prototxt https://gist.github.com/kyrs/e93548079ab9954915122263cf845325 on the basis of the PR in https://github.com/beniz/deepdetect/pull/189 and have merged https://github.com/beniz/deepdetect/pull/174 in my forked branch. but on running the training process training process have thrown following error https://gist.github.com/kyrs/c9dc967bfd49e553cfed10668a4b19e4 .
|
Caffe documentation and examples are a mess, but the comment that explains the required inputs to the RNN and LSTM recurrent layers is here: BVLC/caffe#2033 (comment) As expected this requires modifying the way DD produces the inputs, in order to fit these requirements. I'll make more comments and post potential code to help with this. |
found this interesting document, which explain lstm integration with caffe in more detail. http://tutorial.caffe.berkeleyvision.org/caffe-cvpr15-sequences.pdf |
hi @beniz I am experimenting with dd to run LSTM. I need your suggestion on few stuff, In the example given for training LSTM in caffe the value of \delta is explicitly created and stored in hdf5 format before training or testing the LSTM network. see https://github.com/BVLC/caffe/pull/2033/files#diff-c912186cd39ea15b5646c3b2f5350a7eR105 and https://github.com/BVLC/caffe/pull/2033/files#diff-3a0266c4b6244affd2fd7505a2452f5fR193. Do you think that user should formulate the values of this \delta based on his data and provide it in .prototxt before training or testing or the binary value of this delta should be filled/created in caffe during training or testing based on the batch data. |
|
hi @beniz, I have few doubts regarding modification in Finally I have started to get hang of all these terms. Please, correct me if I am going in wrong direction. |
hi @kyrs ! yes, You can write two lmdb files, they will be synced if you write the entries in the same order. An alternative that DD already uses elsewhere is to put data and deltas into a single Datum and to slice the resting Blob accordingly when running. This requires adding a Slice layer after the data layer If you look at multiple target regression models in DD, they already use the Slice layer. This post https://groups.google.com/forum/m/#!topic/caffe-users/RuT1TgwiRCo can help you with the slicing if you choose this route. Let me know how this goes! |
hi @beniz if you look into the files for generating |
We are padding to, see https://github.com/beniz/deepdetect/blob/master/src/caffeinputconns.h#L786 We fill up the whole sequence with zeros, then fill what we can.
Yes, Let me know if this helps. |
I think that current method of padding the whole sequence with zeros and filling it with appropriate values doesn't preserve the ordering of a words in a given sentence. For LSTM the ordering of word is also important . if you look into https://github.com/BVLC/caffe/pull/2033/files#diff-3a0266c4b6244affd2fd7505a2452f5fR170 the author have appended words in a sequential manner, which clearly preserve the word ordering. what do you think about this ?. I guess we have to change the format in which words are being stored in |
You can change the format, but you could also use the characters instead of words to play with the LSTM. |
I have made some changes in caffeinputconns.h file to integrate it with lstm . Although, I have managed to build it properly, but still I am sceptical about my method. what do you think about it ? https://gist.github.com/kyrs/a1b1065c7bfd92ea48c56f66607b1d0a |
I'm not sure why you are calling |
I am following the multi label classification example https://github.com/beniz/deepdetect/blob/master/src/caffeinputconns.h#L400 to understand the slicing for |
Yes you can change Slicing is not difficult: just append the The fixed length can be relaxed later on, there's no need to try the most complex setup first. Let me know how it goes! |
@beniz is it possible to slice a |
You can slice in any dimension you want, even multiple times. |
The current padding for character does preserve order. The one for words does not since it is a bag of word model. But you could build one that has ordered words. To begin with you might want to try LSTM on ordered characters and thus play with only minimal changes to the existing code. Sent from BlueMail On Oct 22, 2016, 10:59, at 10:59, Kumar Shubham notifications@github.com wrote:
|
sure, I am making changes in the code for character based LSTM prediction. Will soon update you with the results. |
I have created a PR with little modification https://github.com/beniz/deepdetect/pull/208. I think these changes will work. what do you say ? As per next step I am creating |
hi @kyrs, best is to PR once you know that it works :) Have you tried training on an example ? The IMDb dataset would be a good one to use! |
Oops my fault !!! I just wanted to share code with you that's why I created it. if you say so, I will close it for now .. until I tested it completely. |
since you must have pushes it onto your branch, just point me to the branch :) I'll take a look at it tomorrow! |
You can see the changes in https://github.com/kyrs/deepdetect/tree/lstm_140/ |
I have created But, when I tried to test the changes, I got stuck on some issue. Although, I am able to launch the service and start training process with |
run the job with |
Hey guys, exciting to see if LSTM support is possible within DeepDetect also. Did you ever reach a conclusion from your tests in October? Cheers, Hakim |
@hakimkhalafi it hasn't been fulfilled yet. Although we have all the pieces lying on the table, don't expect LSTM support within DD before a few months unless it gets sponsored by one of our customers. Interestingly, the demand for LSTM has been very high. What is the application you are contemplating at the moment if you can share ? |
Hi @beniz, We wanted to implement a CNN + LSTM model. Here we have multiple images and each image is fed to the same CNN, then the fixed size vector output of each image is fed into an LSTM. Would you be knowing about any resources/link/etc which could help in implementing that? Thank You |
Hi @divamgupta DD does not directly support input LSTM layer for production but this should not affect you with images and CNN as first layer, though you may need to re-arrange your inputs. If you already have the Caffe network defined (e.g. Join the gitter chat rather than discussing these details here. |
Hi all, How does one actually use the LSTM layer. I keep getting errors, saying certain parameters are invalid
|
Open an issue and report all requested information, and let's start from there. Thanks. |
Hi,all, I have installed the latest caffe version from the master branch. According to my knowledge Caffe now supports LSTM layers. But when I run the solver I get this error. lstm.prototxt is :
|
You should post this on Caffe issues, you are obviously not using dd. |
RNN + LSTM support now merged into Caffe, BVLC/caffe#3948.
This paves the way for robust integration within dd.
The text was updated successfully, but these errors were encountered: