正如标题所暗示的,预测的输出为1.0或0.0,并且我没有得到任何介于两者之间的值,这导致我的输出下降了100%或下降了100%。
for img in imagesList:
test_image = image.load_img(path+img, target_size=(64, 64))
test_images = image.img_to_array(test_image)
test_images = np.expand_dims(test_image, axis = 0)
result = classifier.predict(test_images)
if result[0][0] <= 0.0:
prediction = 'fall'
print('The file is:{} while model output is: {}{} {} '.format(img[:-4],((1-result[0][0])*100),'%',prediction))
print(result[0][0])
#print('The file is:{} while model output is: {}{} {}'.format(img[:-4],((result[0][0])*100),'%',' nonfall'))
else:
prediction = 'nonfall'
print('The file is:{} while model output is: {}{} {} '.format(img[:-4],((result[0][0])*100),'%',prediction))
print(result[0][0])
答案 0 :(得分:0)
在每个import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-5, 5, 0.01) # need higher resolution to get nice clipping boundaries
y = np.arange(-5, 5, 0.01)
xx, yy = np.meshgrid(x, y) # need dense meshgrid for contains_points
z = np.sin(xx**2 + yy**2) / (xx**2 + yy**2)
patch = plt.Circle((-2, 2), 1) # circle with radius 1 around the point (-2, 2)
path = patch.get_path().transformed(patch.get_patch_transform()) # the path attribute of Circle has to be transformed to data units
is_valid = path.contains_points(np.c_[xx.ravel(), yy.ravel()]).reshape(xx.shape)
z[~is_valid] = np.nan # NaN values are not plotted
h = plt.contourf(xx,yy,z)
plt.plot(-2, 2.5, 'or')
plt.show()
循环迭代中,您将获得单个图像,并且该图像的预测要么是类别,要么是类别。如果要获得批次的准确性,则需要附加批次的图像,然后进行预测。代码应该看起来像这样。
for
答案 1 :(得分:0)