Forráskód Böngészése

bugfix: autotune bucket size manually set

Summary: The bucket part of the matrix is needed only when we compute subwords or when we want to take into account the word-ngrams. Otherwise the bucket size is set to 0. However, when the autotune is activated, the decision to set the bucket size to 0 should be let to autotune strategy.

Reviewed By: EdouardGrave

Differential Revision: D17629756

fbshipit-source-id: f259b7aad562fdd10a813af368171dee57a4a569
Onur Çelebi 6 éve
szülő
commit
1b11e96c5c
3 módosított fájl, 12 hozzáadás és 9 törlés
  1. 1 1
      src/args.cc
  2. 10 8
      src/autotune.cc
  3. 1 0
      src/autotune.h

+ 1 - 1
src/args.cc

@@ -220,7 +220,7 @@ void Args::parseArgs(const std::vector<std::string>& args) {
     printHelp();
     exit(EXIT_FAILURE);
   }
-  if (wordNgrams <= 1 && maxn == 0) {
+  if (wordNgrams <= 1 && maxn == 0 && !hasAutotune()) {
     bucket = 0;
   }
 }

+ 10 - 8
src/autotune.cc

@@ -114,7 +114,8 @@ AutotuneStrategy::AutotuneStrategy(
       trials_(0),
       bestMinnIndex_(0),
       bestDsubExponent_(1),
-      bestNonzeroBucket_(2000000) {
+      bestNonzeroBucket_(2000000),
+      originalBucket_(originalArgs.bucket) {
   minnChoices_ = {0, 2, 3};
   updateBest(originalArgs);
 }
@@ -167,13 +168,14 @@ Args AutotuneStrategy::ask(double elapsed) {
     }
   }
   if (!args.isManual("bucket")) {
-    if (args.wordNgrams <= 1 && args.maxn == 0) {
-      args.bucket = 0;
-    } else {
-      int nonZeroBucket = updateArgGauss(
-          bestNonzeroBucket_, 10000, 10000000, 2.0, 1.5, t, false, rng_);
-      args.bucket = nonZeroBucket;
-    }
+    int nonZeroBucket = updateArgGauss(
+        bestNonzeroBucket_, 10000, 10000000, 2.0, 1.5, t, false, rng_);
+    args.bucket = nonZeroBucket;
+  } else {
+    args.bucket = originalBucket_;
+  }
+  if (args.wordNgrams <= 1 && args.maxn == 0) {
+    args.bucket = 0;
   }
   if (!args.isManual("loss")) {
     args.loss = loss_name::softmax;

+ 1 - 0
src/autotune.h

@@ -28,6 +28,7 @@ class AutotuneStrategy {
   int bestMinnIndex_;
   int bestDsubExponent_;
   int bestNonzeroBucket_;
+  int originalBucket_;
   std::vector<int> minnChoices_;
   int getIndex(int val, const std::vector<int>& choices);