靠后的并行循环不能嵌套在线程下,设置n_jobs = 1

时间:2019-05-26 16:01:12

标签: python parallel-processing multiprocessing pickle nested-loops

我正在尝试释放6个腌制文件,包括1个KNN分类器和2个随机森林分类器:

import pickle
    pkl_filename = "./isrest.pkl"
    with open(pkl_filename, 'rb') as file:  
        restornot = pickle.load(file)
    .
    .
    .

    pkl_filename = "./thumborindexfilter.pkl"
    with open(pkl_filename, 'rb') as file:  
        thumborindexfilter = pickle.load(file)

然后以这种方式在if循环中使用它们:

ftr = np.array([features_extraction_csp(raw_data,restornotfilter)])
    if (restornot.predict(ftr) == 0):
        ftr2 = np.array([features_extraction_csp(raw_data,middleornotfilter)])
        if(middleornot.predict(ftr2) == 0):
            ftr3 = np.array([features_extraction_csp(raw_data,thumborindexfilter)])
            if(thumborindex.predict(ftr3) == 0):
                print("thumb")
                x = {"prediction": str(0) }
                y = json.dumps(x)
                return y  
            else:
                print("index")
                x = {"prediction": str(1) }
                y = json.dumps(x)
                return y  
        else:
            print("middle")
            x = {"prediction": str(2) }
            y = json.dumps(x)
            return y
    else:
        print("rest")
        x = {"prediction": str(3) }
        y = json.dumps(x)
        return y

但是我遇到了这个错误:

    UserWarning: Loky-backed parallel loops cannot be nested below threads, setting n_jobs=1
  n_jobs = min(effective_n_jobs(n_jobs), n_estimators)

任何帮助将不胜感激

0 个答案:

没有答案