-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Transform layers [DON'T MERGE] #569
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
Conversation
|
Note that this would have substantial speed and memory overhead vs. the current implementation as all of this stuff is currently done on the next batch by the prefetch thread while the current batch is being run through the net; this moves it to the forward pass. Unless I'm misunderstanding the intent here. |
|
In the past the idea came up of a PREFETCH phase so that we could specify At any rate, I agree that whatever the design it needs to not incur a bunch Le lundi 30 juin 2014, Jeff Donahue notifications@github.com a écrit :
Evan Shelhamer |
|
I was planning on keeping the prefetch in the next batch within the data The transform layers don't need to know about that. The data layer will I was also thinking in adding multiple threads to process the blobs in We could discuss the architecture later in person. On Monday, June 30, 2014, Evan Shelhamer notifications@github.com wrote:
Sergio |
|
Even if these layers are run inside the prefetch thread there's still a speed and memory cost (at least for most of the transformations). For example, when cropping is enabled, we never store the entire uncropped image in a blob, which would be a huge cost in both speed and memory if you're training on small patches of the input image. Since mirroring doesn't change the size, it could be done "in place" to use almost no additional memory, but you still have the speed cost of copying the un-mirrored image in the first place. |
|
There will be some memory overhead if we transform all images at once. But we could apply all the transformations one image at the time, and iterate to avoid extra memory. I think this approach should be faster if we can process several images in parallel with different threads. Although we could add a |
|
We could pull the current method into a base data layer that still does Let's talk this afternoon in person like @sguada suggested. Le lundi 30 juin 2014, Sergio Guadarrama notifications@github.com a
|
|
Probably we can abstract most of the common things, but that will depend if I think that in the long run having the ability to do different Sergio 2014-06-30 10:56 GMT-07:00 Evan Shelhamer notifications@github.com:
|
|
Agreed–the point of this re-design is to make everything more configurable
Maybe it's best if we turn everything into blob, and if we pay a per-batch On Mon, Jun 30, 2014 at 11:20 AM, Sergio Guadarrama <
|
|
Back in #244, I tried many APIs to unify the preprocessing steps for different data formats but gave up. The new design would possibly consist of data IO including prefetching, data format conversions and finally data content transformations. The data IO takes care of the various data sources such as leveldb/lmdb, HDF5, images on the disk and from memory. To avoid replicating the preprocessing codes for each format, the raw data should be converted into Blob. Although the layers have been a very important part of Caffe. They have unified method interfaces and we are all accustomed to wrapping many things into them. But certainly not everything needs to be a layer. The conversions and transformations are better put in simpler classes to allow for in-place data manipulations. I have used boost::thread to parallelize the performance critical parts in a few projects. It is cross platform and has much more flexible API than pthread. Multiple threads for a common task can be effectively managed in thread_group. We should definitely switch to it to be future-proof. |
|
One of the advantage of boost threads is that will be very easy to switch to c++11 threads when cuda version will let us to switch to a modern version of gcc. |
4278286 to
c01f07a
Compare
|
@sguada Can we discuss here if this layer could be compatible and useful also for data augmentation (light changes, elastic distortion, affine transformation, Gaussian noise, motion blur etc.). I think that some operation (when we handle image data) probably are easier and more optimized to do in opencv but at this level we are handling blob so I don't know how we could introduce pluggable augmentation operators. |
|
@bhack maybe doing data augmentation would be easier within Transform_Data. Within #1070 during the transformation of cv::Mat to Blob we could use any opencv routine. |
|
Closing as abandoned. We agree with the motivation (data transformers becoming layers of their own rather than applied by each data layer) but this needs a bit more thought (prefetching etc., see discussion above) and a rebase. |
|
@sguada are there RGB jittering in caffe?Thank you |
|
I don't think so, but you could implement them easily using other layers. Sergio 2015-06-01 0:30 GMT-07:00 whjxnyzh notifications@github.com:
|
This is a tentative approach to add transformation layers that would allow to crop_mirror, center_scale the blobs.
The first use would be to help Data source and pre-processing separation. The source would produce a vector of blobs, one per image, the transformation layers and finally concat all the blobs into one.
The concept is similar to do
map(transformation, bottom_blobs, top_blobs)@Yangqing What do you think?