Conversation
57da235 to
796d996
Compare
796d996 to
285ae3d
Compare
285ae3d to
71cf0e5
Compare
| optional LossParameter loss_param = 101; | ||
|
|
||
| // Specify name of source class | ||
| optional string source_class = 143; |
There was a problem hiding this comment.
This should be a field in MemoryDataParameter, not LayerParameter if I understand this patch.
There was a problem hiding this comment.
Agree. Also, this parameter (along with source) needs some more explanation, as right now they seem unused in Caffe. Why are we adding these?
There was a problem hiding this comment.
This pull request is motivated by making Caffe work on Spark (via CaffeOnSpark). source_class was used by CaffeOnSpark to decide which particular Scala class to use for handling a given data source. See CaffeOnSpark code.
Our original idea is to support custom sources for data layers beyond MemoryDataLayer. For example, to support NLP use cases, we have introduced a VWDataLayer. That's why we propose an optional field at LayerParameter. By having source_class at LayerParemeter, we will enable CaffeOnSpark users to introduce customized parser for different data layers.
FYI, VWDataParameter is defined as below:
message VWDataParameter {
optional string source = 1;
optional uint32 batch_size = 2;
optional bool shuffle = 3 [default = false];
message TopLayer{
optional string name = 1;
optional string type = 2;
optional uint32 channels = 3;
optional uint32 height = 4;
optional uint32 width = 5;
optional string vw_namespace = 6;
}
repeated TopLayer top = 4;
optional bool sparse = 5 [default = false];
optional bool memory_input = 6[default = false];
}
|
Comments as noted; also, the logic here does not seem quite right. In this patch we step through device memory in GPU mode, and host memory in CPU mode. But what if we give this layer a host pointer in GPU mode? (Or (should this even be allowed?) a device pointer in CPU mode?) It looks like this patch will break things, even though (at least the former case) works fine as-is (and is a pretty common case!). So it seem like the action of Forward should really depend on the pointer type, not the mode. (And given that this is not totally straightforward, it would be nice to have a test to check these cases.) |
|
Regarding the last comment, we assume memory layer gets a host pointer in the CPU mode (hence Forward_cpu) and a device pointer in the GPU mode (hence Forward_gpu). Is this a good assumption? Maybe we should add a few assertions to check that. |
No. As noted above, this assumption is violated in practice. The way I've most commonly used |
|
Can we assume the following:
|
|
Closing according to #5528. Thanks for the effort to improve this troubled layer all the same. |
This PR enhances memory data layer with:
This PR introduce an optional parameter for LayerParameter: