Hello Guys I am new to Machine and Trying to learn it from you-tube but when i run their code on my computer i got this error Please help....!!!!
Code:
import random
random.shuffle(training_data)
for sample in training_data:
print(sample[1])
X = []
y = []
y = np.array(y)
for features , label in training_data:
X.append(features)
y.append(label)
X = np.array(X).reshape(-1 , IMG_SIZE , IMG_SIZE,1)
Move your y to numpy to after loop. As @Tyberius mentioned in the comments, you cannot append to numpy array. Therefore, you need to keep y
as list in your for loop and then convert it after appending. Like here:
import random
random.shuffle(training_data)
for sample in training_data:
print(sample[1])
X = []
y = []
for features , label in training_data:
X.append(features)
y.append(label)
y = np.array(y)
X = np.array(X).reshape(-1 , IMG_SIZE , IMG_SIZE,1)
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.