那是我的代码:
test_image = image.load_img('dataset/single_prediction/cat_or_dog_1.jpg', target_size = (64, 64))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis = 0)
result = classifier.predict(test_image)
training_set.class_indices
if result[0][0] == 1:
prediction = 'dog'
else:
prediction = 'cat' `
我有这样的错误:
File "<ipython-input-31-35ebf5fa8bf7>", line 7
prediction = 'dog'
^
IndentationError: expected an indented block
谁能帮我?
最佳答案
您的代码没有正确缩进:
test_image = image.load_img('dataset/single_prediction/cat_or_dog_1.jpg', target_size = (64, 64))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis = 0)
result = classifier.predict(test_image)
training_set.class_indices
if result[0][0] == 1:
prediction = 'dog'
else:
prediction = 'cat'
关于python - IndentationError:需要缩进的块-Python机器学习的猫/狗,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53595043/