-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Indirection layer #1414
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
Indirection layer #1414
Conversation
|
The project maintainers are probably hibernating. |
http://www.pamitc.org/cvpr15/dates.php So only until next week (Saturday and Sunday to sleep after submission :)) |
|
Have the project maintainers awaken from their prolonged hibernation? |
|
@shelhamer @longjon @sguada @jeffdonahue what is the BVLC team status now? |
|
Supplementary material. We're all nearly back and preparing pull requests,
|
|
The description of this PR is updated to better clarify what this layer does. |
|
@shelhamer @longjon @sguada @jeffdonahue Is there any status update? I would like this PR to be merged upstream as soon as possible, because I have other ideas to implement, and maintaining several feature branches at the same is becoming increasingly difficult. |
|
@netheril96 This problem is common. There is no "known" policy for users contribution reviews. It is not about the age of the PR. It is not about the quality of the PR. It is not about the triviality of the PR. |
|
@netheril96 after looking over this PR, I think it should be splitted in two PRs:
The second PR should be an indirection layer (which should be part of data_layers.hpp) and uses a datasource (or labelsource) to read the labels and provide them when requested. Also I think being able to read data from txt files, binary files or blob files will be a good addition to datasource. |
|
Your idea of a further abstraction is interesting, but I have not completely understood it. For one, there is no reading labels from files, blobs, DB in this PR. The only real labels are from
If I understand it correctly, the keys in the key-value store (leveldb or lmdb) currently has not much semantic meaning. They are all prepended with the ascii representation of an integer to enforce ordering, and is not amenable to random access, not the current interface anyway. Or do you propose we change that too? |
|
Actually isn't |
@sguada in general I think there should not be a real distinction between data and label, but instead there should be only blob. I don't want to make this off-topic so I'll post another issue. |
|
@shelhamer Agreed, that is what I was trying to say, data and label should be treated more uniformly. Unfortunately, currently Datum makes a clear distinction between data (which can be int8 or float 3D-matrix) and label (which can only be int). For the unification I see three options:
In any case the source should contain the type of the data/label stored. |
|
@netheril96 I forgot to mention that |
About data and label
Label is a special case of data (1x1x1 3D matrix), so they are already unified.
This seems not true. Without indirection layer, both are retrieved sequentially. If you are referring to the string key in leveldb/lmdb, currently they are not meaningful and are never used. In a nutshell, I strongly disagree with the suggestion that we should make distinction between data and label. The latter is but a special case of the former, and they are already unified under the interface About representation
I considered such design in the beginning, and decided to go for a simpler approach. But maybe that was wrong. The alternative as I am currently thinking is to mandate that the source file is of text protobuf format. The structure can be declared as message DataMappingEntry {
required int64 key = 1;
required string type = 2;
repeated float data = 3;
optional string filename = 4;
}
message DataMapping {
repeated DataMappingEntry entry;
}This has several changes with respect to current design:
MiscI am not sure whether to put this layer. Conceptually, this layer does belong to data layers. But all the layers in |
|
Some comments:
So the path I see is: break this into some data layers that take indices and produce data, and/or add options to existing data layers to take bottom blobs that contain indices, where that can be done and is desired. (However, I'm a newcomer to this PR, so let me know if I've missed some reason why things should be done differently.) |
|
And @bhack @netheril96, re: the reviewing process, I agree that we could be a bit more organized, and know that we are discussing how we can improve things to be more efficient with everyone's time. In the case of this PR, I can say why I personally haven't had time for a close look: it's a behemoth at nine hundred lines, including hundreds of lines added to (If you have more to say about the process, let's take it to an issue to keep this on topic.) |
Eh, isn't "keys as bottom and data as tops" exactly what
Are you suggesting that a different layer is made for each different type of data mapping? Like The current design is that
My intention is to give users freedom of choices of data format, and the design is modular (or so I wish), but with many small modules. In fact, the several choices I give the users are pretty trivial, the corresponding class light, and was meant to demonstrate the flexibility and extensibility of this design. Apparently this choice has backfired. Maybe we should instead agree on an one true format, and thus dramatically cut down the lines of code needed. |
|
Perhaps I was ahead of myself when I accounted for various scenarios that may or may not be applicable in practice. After the discussion here is my revised design:
These two decision should cut down the lines of code needed and improve performance (the caching mechanism I wrote is primitive). If no major disagreement is found with such design, I will implement it in the following days. Hopefully feedback can be quicker this time. |
|
I think having multiple ways to define data/labels and load them is good, but it should be isolated from the layers, including DataLayers and IndirectLayer (what about renaming as EmbedingLayer or MappingLayer) So the indirect layer should allow different I would create a new message in caffe.proto that allows to define different types of sources. An indirect layer would define one of those sources. Assuming |
So you think the current design of It also appears that you want to unify |
|
@mtamburrano, Can you please share your multi-label training example with us? |
|
@amiralush When all the involved PR will be merged in dev we can try to port our network to SVHN, if we have enough spare time, and share it in model zoo. |
|
It has come to my attention that |
|
@netheril96 |
|
@shelhamer It is very odd that no one, including you, had even hinted at it. |
|
@shelhamer So using HDF5DataLayer will be officially the only solution to produce multiple blobs? |
|
@bhack @netheril96 From recent experience it seems that forming a new, general data pipeline without a lot of complications is a tricky task so light, decisively useful changes like #1183 are important steps. |
|
So you mean that this |
|
@netheril96 I don't know yet -- more code takes more time to review and really work out the consequences for the framework. It's important to have different proposals to understand the options and pick the right way, so thanks for this interpretation of how to load rich data from an integer index. |
|
Can somebody tag this PR as abandoned by reviewers? |
This is an new layer implemented, as mentioned in #523. The
IndirectionLayermaps each single integer label into an arbitrary blob. The mapping is stored in the file specified by thesourceparameter.Motivation
In a lot of cases, more than a single integer label for each image is needed. It may be a group of independent labels, or linear array/matrix, or a combination of both. The current workarounds is to create multiple
DataLayerandImageDataLayer, each outputting a data array. The problem with this approach isDataLayerorImageDataLayer. This approach is basically a hack that abuses the existing layers.The
Datumformat can be reworked to allow arbitrary data in place of a single label. That approach, however, is likely to complicate the majority of use cases where a single label is already enough, and/or break backwards compatibility.Network structure with indirection layer
In the first example, the single label output of
DataLayeris transformed to three independent labels, suitable for three different loss layers.In the second example, the label output is transformed into a large blob instead. Hence images (or other data) can have arbitrary data naturally associated.
More complex network can be constructed by adding several indirection layers so that each data can be associated with arbitrary number of arbitrary properties with arbitrary shapes.
Basic usage
The
indirection_paramis declared asThe key attributes are
typeandsource. Thesourceattribute contains the file name of a text file containing the mapping and can be repeated to produce multiple tops. In each mapping file, the zeroth line indicates the zeroth blob, the 33rd line the 33rd blob, etc.The
typeparameter determines how each line is interpreted. In the default case, each line composes of space separated floating numbers. They may also be interpreted as file names that contains the actual data. Moretype(such as indexed images) can be added by subclassingIndexedDataReader.The
channels,widthandheightattributes control the shape of top blob, and must be specified (or left with default value 1) because many type of mapping does not contain the relevant information. Changing these values can allow different interpretation of underlying data contained in the mapping.When the
typeis notSIMPLE_TEXT, each lookup requires disk access and possibly format conversion, which is costly. To reduce the overhead, one can enable caching. Currently only the simplest caching mechanism are implemented: complete in memory cache and block cache with CLOCK replacement algorithm. More cache strategy can be implemented by subclassingIndexedCachedDataReader.