在 Rasbperry Pi 3 上運行 Python 時,我在多處理池中使用 train_test_split 遇到了一些奇怪的行為。我有這樣的事情:def evaluate_Classifier(model,Features,Labels,split_ratio): X_train, X_val, y_train, y_val = train_test_split(Features,Labels,test_size=split_ratio)...iterations=500pool = multiprocessing.Pool(4)results = [pool.apply_async(evaluate_Classifier, args=(w,Current_Features,Current_Labels,0.35)) for i in range(iterations)]output = [p.get() for p in results]pool.close()pool.join()現在上面的代碼在 Windows 7 Python 3.5.6 上完美運行,實際上 4 個線程中的每一個都會有不同的訓練/測試分割。但是,當我在 Raspberry Pi 3 (scikit-learn 0.19.2) 上運行它時,似乎 4 個線程以完全相同的方式拆分數據,因此所有線程產生完全相同的結果。接下來的 4 個線程將再次拆分數據(這次不同),但它們之間的方式仍然完全相同,依此類推....我什至嘗試使用帶有 random_state=np.random.randint 的 train_test_split,但它沒有幫助。任何想法為什么這在 Windows 中有效,但在 raspberry Pi 3 上似乎不能正確并行化?
Linux (armv7l) 上的多處理池中的 Scikit-learn train_test
慕田峪7331174
2021-06-12 11:01:22