small fixes
authormanuele <manuele.tamburrano@gmail.com>
Thu, 8 Jan 2015 18:26:20 +0000 (19:26 +0100)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Sat, 7 Feb 2015 04:55:31 +0000 (20:55 -0800)
src/caffe/layers/memory_data_layer.cpp
src/caffe/test/test_memory_data_layer.cpp

index 214f9d8..73b9f49 100644 (file)
@@ -35,12 +35,10 @@ void MemoryDataLayer<Dtype>::AddDatumVector(const vector<Datum>& datum_vector) {
       << " by the upper layers";
   size_t num = datum_vector.size();
   CHECK_GT(num, 0) << "There is no datum to add";
-  CHECK_LE(num % batch_size_, 0) <<
+  CHECK_EQ(num % batch_size_, 0) <<
       "The number of added datum must be multiple of the batch size";
-  if (num > batch_size_) {
-    added_data_.Reshape(num, channels_, height_, width_);
-    added_label_.Reshape(num, 1, 1, 1);
-  }
+  added_data_.Reshape(num, channels_, height_, width_);
+  added_label_.Reshape(num, 1, 1, 1);
   // Apply data transformations (mirror, scale, crop...)
   this->data_transformer_.Transform(datum_vector, &added_data_);
   // Copy Labels
@@ -61,13 +59,11 @@ void MemoryDataLayer<Dtype>::AddMatVector(const vector<cv::Mat>& mat_vector,
   CHECK(!has_new_data_) <<
       "Can't add Mat when earlier ones haven't been consumed"
       << " by the upper layers";
-  CHECK_LE(num % batch_size_, 0) <<
+  CHECK_EQ(num % batch_size_, 0) <<
       "The number of added datum must be multiple of the batch size";
   CHECK_GT(num, 0) << "There is no mat to add";
-  if (num > batch_size_) {
-    added_data_.Reshape(num, channels_, height_, width_);
-    added_label_.Reshape(num, 1, 1, 1);
-  }
+  added_data_.Reshape(num, channels_, height_, width_);
+  added_label_.Reshape(num, 1, 1, 1);
   // Apply data transformations (mirror, scale, crop...)
   this->data_transformer_.Transform(mat_vector, &added_data_);
   // Copy Labels
index bc6c9b4..d4d5710 100644 (file)
@@ -247,8 +247,7 @@ TYPED_TEST(MemoryDataLayerTest, TestChangeBatchSize) {
           for (int c = 0; c < this->channels_; ++c) {
             data_index = (i*count) + (c * this->height_ + h) * this->width_ + w;
             Dtype pixel = static_cast<Dtype>(ptr_mat[index++]);
-            EXPECT_EQ(static_cast<int>(pixel),
-                      data[data_index]);
+            EXPECT_EQ(static_cast<int>(pixel), data[data_index]);
           }
         }
       }
@@ -284,8 +283,7 @@ TYPED_TEST(MemoryDataLayerTest, TestChangeBatchSize) {
           for (int c = 0; c < this->channels_; ++c) {
             data_index = (i*count) + (c * this->height_ + h) * this->width_ + w;
             Dtype pixel = static_cast<Dtype>(ptr_mat[index++]);
-            EXPECT_EQ(static_cast<int>(pixel),
-                      data[data_index]);
+            EXPECT_EQ(static_cast<int>(pixel), data[data_index]);
           }
         }
       }