MCPcopy Create free account
hub / github.com/BVLC/caffe / DataLayerSetUp

Method DataLayerSetUp

src/caffe/layers/data_layer.cpp:29–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28template <typename Dtype>
29void DataLayer<Dtype>::DataLayerSetUp(const vector<Blob<Dtype>*>& bottom,
30 const vector<Blob<Dtype>*>& top) {
31 const int batch_size = this->layer_param_.data_param().batch_size();
32 // Read a data point, and use it to initialize the top blob.
33 Datum datum;
34 datum.ParseFromString(cursor_->value());
35
36 // Use data_transformer to infer the expected blob shape from datum.
37 vector<int> top_shape = this->data_transformer_->InferBlobShape(datum);
38 this->transformed_data_.Reshape(top_shape);
39 // Reshape top[0] and prefetch_data according to the batch_size.
40 top_shape[0] = batch_size;
41 top[0]->Reshape(top_shape);
42 for (int i = 0; i < this->prefetch_.size(); ++i) {
43 this->prefetch_[i]->data_.Reshape(top_shape);
44 }
45 LOG_IF(INFO, Caffe::root_solver())
46 << "output data size: " << top[0]->num() << ","
47 << top[0]->channels() << "," << top[0]->height() << ","
48 << top[0]->width();
49 // label
50 if (this->output_labels_) {
51 vector<int> label_shape(1, batch_size);
52 top[1]->Reshape(label_shape);
53 for (int i = 0; i < this->prefetch_.size(); ++i) {
54 this->prefetch_[i]->label_.Reshape(label_shape);
55 }
56 }
57}
58
59template <typename Dtype>
60bool DataLayer<Dtype>::Skip() {

Callers 1

TYPED_TESTFunction · 0.45

Calls 9

batch_sizeMethod · 0.80
InferBlobShapeMethod · 0.80
numMethod · 0.80
valueMethod · 0.45
ReshapeMethod · 0.45
sizeMethod · 0.45
channelsMethod · 0.45
heightMethod · 0.45
widthMethod · 0.45

Tested by 1

TYPED_TESTFunction · 0.36