Выход из модели CNN составляет либо 1,0, либо 0,0 - PullRequest
0 голосов
/ 04 мая 2020

Как видно из заголовка, выходные данные прогноза равны либо 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])

Ответы [ 2 ]

0 голосов
/ 05 мая 2020

РЕДАКТИРОВАТЬ:

Я решил проблему с помощью model.predict_prob(img).

См .: { ссылка }

0 голосов
/ 04 мая 2020

В каждой итерации for l oop вы получаете одно изображение, и его прогнозом является любая категория. Если вам нужна точность по сравнению с пакетом, вам нужно добавить изображения серии и затем прогнозировать. Код должен выглядеть примерно так:

image_batch = []

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)
    image_batch.append(np.array(test_images))

result = classifier.predict(image_batch)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...