简体   繁体   中英

How to fix the following error: ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required

I am trying to train a CNN model and after the first epoch I got the following error:

ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.

Look like it is complaining about the following line:

X = onehot.transform(df.iloc[start_index: end_index][['Num1','Num2']])

Check start_index and end_index.

I think start_index is bigger than end_index, or start_index is bigger than the number of samples.

Actually this is because of undefined array:

from sklearn.utils.validation import check_array
import numpy as np 

X = np.array([(3,6),(3,6)])
array = check_array(X,ensure_min_samples=2)
print(array)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM