[Product Ratings] Fix inconsistent batch
authorJihoon Lee <jhoon.it.lee@samsung.com>
Wed, 2 Jun 2021 06:42:00 +0000 (15:42 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Wed, 2 Jun 2021 09:41:43 +0000 (18:41 +0900)
This patch fixes inconcistent batch size between source file and model
configuration.

Also found a bug #1238, which will be dealt seperately.

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
Applications/ProductRatings/jni/main.cpp

index f304696..971b7f2 100644 (file)
@@ -33,7 +33,7 @@ const unsigned int total_train_data_size = 25;
 
 unsigned int train_count = 0;
 
-const unsigned int batch_size = 10;
+const unsigned int batch_size = 20;
 
 const unsigned int feature_size = 2;
 
@@ -134,8 +134,9 @@ int getBatch_train(float **outVec, float **outLabel, bool *last,
       return -1;
     }
 
-    for (unsigned int j = 0; j < feature_size; ++j)
+    for (unsigned int j = 0; j < feature_size; ++j) {
       outVec[0][count * feature_size + j] = o[j];
+    }
     outLabel[0][count] = l[0];
 
     count++;
@@ -219,9 +220,9 @@ int main(int argc, char *argv[]) {
   if (training) {
     NN.setDataset(dataset);
     try {
-      NN.train();
-    } catch (...) {
-      std::cerr << "Error during train" << std::endl;
+      NN.train({"batch_size=" + std::to_string(batch_size)});
+    } catch (std::exception &e) {
+      std::cerr << "Error during train " << e.what() << std::endl;
       return 1;
     }