Просмотр исходного кода

Better default for number of threads

Summary: Pull Request resolved: https://github.com/facebookresearch/fastText/pull/659

Reviewed By: piotr-bojanowski

Differential Revision: D13318793

Pulled By: Celebio

fbshipit-source-id: 3b8fd28172b0291b2df93a526de630b01df680e8
Krishna Sangeeth 7 лет назад
Родитель
Сommit
501b9b1e45
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      python/fastText/FastText.py

+ 3 - 2
python/fastText/FastText.py

@@ -12,6 +12,7 @@ from __future__ import unicode_literals
 
 import fasttext_pybind as fasttext
 import numpy as np
+import multiprocessing
 
 loss_name = fasttext.loss_name
 model_name = fasttext.model_name
@@ -334,7 +335,7 @@ def train_supervised(
     wordNgrams=1,
     loss="softmax",
     bucket=2000000,
-    thread=12,
+    thread=multiprocessing.cpu_count() - 1,
     lrUpdateRate=100,
     t=1e-4,
     label="__label__",
@@ -375,7 +376,7 @@ def train_unsupervised(
     wordNgrams=1,
     loss="ns",
     bucket=2000000,
-    thread=12,
+    thread=multiprocessing.cpu_count() -1,
     lrUpdateRate=100,
     t=1e-4,
     label="__label__",