前提・実現したいこと
Ubuntuで実行できない理由を知りたいです。
MacOSでは実行できたプログラムをParallelsの仮想環境のUbuntuで実行したら下記のようなエラーが出ました。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "gen_data.py", line 28, in <module> X_train, X_test, y_train, y_test = model_selection.train_test_split(X, Y, test_size=0.20) File "/home/parallels/Downloads/applications/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 2122, in train_test_split default_test_size=0.25) File "/home/parallels/Downloads/applications/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 1805, in _validate_shuffle_split train_size) ValueError: With n_samples=0, test_size=0.2 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.
該当のソースコード
Python
1from PIL import Image 2import os, glob 3import numpy as np 4from sklearn import model_selection 5 6classes = ['Orange', 'OrangeTree'] 7num_classes = len(classes) 8image_size = 50 9 10#画像の読み込み 11X = [] 12Y = [] 13for index, classlabel in enumerate(classes): 14 photos_dir = './Image/' + classlabel 15 files = glob.glob(photos_dir + '*.jpg') 16 for i, file in enumerate(files): 17 if i >= 200: break 18 image = Image.open(file) 19 image = image.convert('RGB') 20 image = image.resize((image_size, image_size)) 21 data = np.asarray(image) 22 X.append(data) 23 Y.append(index) 24 25X = np.array(X) 26Y = np.array(Y) 27 28X_train, X_test, y_train, y_test = model_selection.train_test_split(X, Y, test_size=0.20) 29xy = (X_train, X_test, y_train, y_test) 30np.save('./orangeai.npy', xy) 31
Ubuntu18.04
Pythonバージョン
MacOS : 3.6.10
Ubuntu : 3.7.6
実行コマンド
MacOS : python gen_data.py
Ubuntu : python gen_data.py
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー