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

Method AddMatVector

src/caffe/layers/memory_data_layer.cpp:58–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56#ifdef USE_OPENCV
57template <typename Dtype>
58void MemoryDataLayer<Dtype>::AddMatVector(const vector<cv::Mat>& mat_vector,
59 const vector<int>& labels) {
60 size_t num = mat_vector.size();
61 CHECK(!has_new_data_) <<
62 "Can't add mat until current data has been consumed.";
63 CHECK_GT(num, 0) << "There is no mat to add";
64 CHECK_EQ(num % batch_size_, 0) <<
65 "The added data must be a multiple of the batch size.";
66 added_data_.Reshape(num, channels_, height_, width_);
67 added_label_.Reshape(num, 1, 1, 1);
68 // Apply data transformations (mirror, scale, crop...)
69 this->data_transformer_->Transform(mat_vector, &added_data_);
70 // Copy Labels
71 Dtype* top_label = added_label_.mutable_cpu_data();
72 for (int item_id = 0; item_id < num; ++item_id) {
73 top_label[item_id] = labels[item_id];
74 }
75 // num_images == batch_size_
76 Dtype* top_data = added_data_.mutable_cpu_data();
77 Reset(top_data, top_label, num);
78 has_new_data_ = true;
79}
80#endif // USE_OPENCV
81
82template <typename Dtype>

Callers 1

TYPED_TESTFunction · 0.80

Calls 4

TransformMethod · 0.80
sizeMethod · 0.45
ReshapeMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by 1

TYPED_TESTFunction · 0.64