forked from BVLC/caffe
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an input layer to replace oddball Net `input` fields. close BVLC#1245
- Loading branch information
Showing
3 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <vector> | ||
|
||
#include "caffe/filler.hpp" | ||
#include "caffe/layer.hpp" | ||
#include "caffe/vision_layers.hpp" | ||
|
||
namespace caffe { | ||
|
||
template <typename Dtype> | ||
void InputDataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, | ||
const vector<Blob<Dtype>*>& top) { | ||
const int num_top = top.size(); | ||
const InputDataParameter& param = this->layer_param_.input_data_param(); | ||
const int num_shape = param.shape_size(); | ||
CHECK(num_shape == 0 || num_shape == 1 || num_shape == num_top) | ||
<< "Must specify 'shape' once, once per top blob, or not at all: " | ||
<< num_top << " tops vs. " << num_shape << " shapes."; | ||
if (num_shape > 0) { | ||
for (int i = 0; i < num_top; ++i) { | ||
const int shape_index = (param.shape_size() == 1) ? 0 : i; | ||
top[i]->Reshape(param.shape(shape_index)); | ||
} | ||
} | ||
} | ||
|
||
INSTANTIATE_CLASS(InputDataLayer); | ||
REGISTER_LAYER_CLASS(InputData); | ||
|
||
} // namespace caffe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters