Regression (sort of) with dynamically generated training examples

75 views
Skip to first unread message

Pastafarianist

unread,
Apr 23, 2015, 6:39:08 PM4/23/15
to caffe...@googlegroups.com
I am working on a real-world character recognition problem. I'd like to take an image of a string of digits and, well, turn it into a string. The standard approach of segmentation based on connected components followed by HOG+SVM has failed due to poor image quality, so I am exploring whether a neural network would work better. I have a bunch of training examples, but far too few to run any sensible training. So I'm generating more examples artificially. Specifically, I generate a string of MNIST digits which looks like the ones I'm trying to recognize. Then I run a sliding window across it, generating a few dozens of patches. To each patch I assign an array of probabilities. The patches that sit directly on top of digits get probability 1 in that digit's class and 0 in others. In other patches I interpolate probabilities between the two nearest digits.

Thus, I'd like to train the network on images that are generated on-the-fly and have an array of class probabilities assigned to them, not a single class ID. I am doing generation in Python.
  1. As far as I know, MemoryData layer is the only (currently officially available) way to train the network from Python, and it accepts class IDs as labels, not arrays. Is that correct?
  2. As a crude but working solution, I could avoid the problem of lacking Python interface by storing a few hundred thousand generated training examples in a database instead of generating them on-the-fly and running the usual caffe binary. But convert_imageset expects class IDs, not arrays. If (1) is correct, how do I generate a database?
  3. Would SigmoidCrossEntropyLoss be a good choice for the final layer?
  4. Stepping a bit aside, is this a good approach to character recognition?
I would be extremely grateful if someone could help me with some of these questions.

Axel Angel

unread,
Apr 27, 2015, 8:44:12 AM4/27/15
to caffe...@googlegroups.com
(2) I wrote my own Python program to generate datasets in LMDB, so I can train them with caffe. I like having a dataset on-disk so I can open it easily. You can find examples how to write LMDB in other threads.
Reply all
Reply to author
Forward
0 new messages