Мы хотели бы разделить наши данные на 3 части, однако получаем следующую ошибку:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Ниже вы можете увидеть наш python -код:
data = pd.read_csv('/content/drive/My Drive/GTruth.csv')
def dataset_gen(data, size = (224,224,3)):
img_data = []
labels = []
directory='/content/drive/My Drive/Lungenbilder_gekürzt'
for filename in os.listdir(directory) :
if filename.endswith(".jpeg") or filename.endswith(".jpg"):
#for img_name, pollen_carrying in zip(data['Id'], data['Ground_Truth']):
img = io.imread(os.path.join(str(directory), str(filename)))
img = transform.resize(img, size, mode = 'constant')
img_data.append(img)
labels.append(kv_dict.get((filename.split('.')[0])))
else:
continue
return np.array(img_data), np.array(labels)
x, y = dataset_gen(data)
#Train Test Split
X_train, X_1, y_train, y_1 = train_test_split(x, y, test_size=0.5, random_state=42)
y_train = tf.keras.utils.to_categorical(y_train, num_classes = 2) #erstellt Matrix
y_1 = tf.keras.utils.to_categorical(y_1, num_classes = 2)
#Train Test Split
X_cv, X_test, y_cv, y_test = train_test_split(X_1, y_1, test_size=0.2, random_state=42)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-116-474212bb9856> in <module>()
2 X_train, X_1, y_train, y_1 = train_test_split(x, y, test_size=0.5, random_state=42)
3
----> 4 y_train = tf.keras.utils.to_categorical(y_train, num_classes = 2) #erstellt Matrix
5 y_1 = tf.keras.utils.to_categorical(y_1, num_classes = 2)
6
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/np_utils.py in to_categorical(y, num_classes, dtype)
67
68 """
---> 69 y = np.array(y, dtype='int')
70 input_shape = y.shape
71 if input_shape and input_shape[-1] == 1 and len(input_shape) > 1:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Спасибо за вашу помощь!
Сандра и Леон ie