편집 기록

편집 기록
  • 프로필 정영훈님의 편집
    날짜2019.12.27

    python 질문


    import tensorflow.keras
    from PIL import Image
    import numpy as np
    
    np.set_printoptions(suppress=True)
    
    model = tensorflow.keras.models.load_model('keras_model.h5')
    
    data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
    image = Image.open('skoda.jpg')
    
    image = image.resize((224, 224))
    image_array = np.asarray(image)
    
    normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1
    
    data[0] = normalized_image_array
    
    prediction = model.predict(data)
    print("Ford",prediction[0,0])
    print("Fox",prediction[0,1])
    print("Hundae",prediction[0,2])
    print("Lexus",prediction[0,3])
    print("Ferrari",prediction[0,4])
    print("Chevrolet",prediction[0,5])
    print("Nissan",prediction[0,6])
    print("Skoda",prediction[0,7])
    print(prediction)
    

    실행시

     Ford 8.9526235e-05
    Fox 0.00031412177
    Hundae 2.5784022e-05
    Lexus 1.4473101e-05
    Ferrari 0.008922634
    Chevrolet 3.905558e-05
    Nissan 5.2737455e-06
    Skoda 0.99058914
    [[0.00008953 0.00031412 0.00002578 0.00001447 0.00892263 0.00003906
      0.00000527 0.99058914]]
    

    로 출력이 되는데 소수점 부분부터 출력이 안되고 저렇게 출력이 되는데 어떻게 해야 수정이 가능할까요??

  • 프로필 알 수 없는 사용자님의 편집
    날짜2019.12.26

    python 질문


    import tensorflow.keras from PIL import Image import numpy as np

    np.set_printoptions(suppress=True)

    model = tensorflow.keras.models.load_model('keras_model.h5')

    data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32) image = Image.open('skoda.jpg')

    image = image.resize((224, 224)) image_array = np.asarray(image)

    normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1

    data[0] = normalized_image_array

    prediction = model.predict(data) print("Ford",prediction[0,0]) print("Fox",prediction[0,1]) print("Hundae",prediction[0,2]) print("Lexus",prediction[0,3]) print("Ferrari",prediction[0,4]) print("Chevrolet",prediction[0,5]) print("Nissan",prediction[0,6]) print("Skoda",prediction[0,7]) print(prediction)

    실행시 Ford 8.9526235e-05 Fox 0.00031412177 Hundae 2.5784022e-05 Lexus 1.4473101e-05 Ferrari 0.008922634 Chevrolet 3.905558e-05 Nissan 5.2737455e-06 Skoda 0.99058914 [[0.00008953 0.00031412 0.00002578 0.00001447 0.00892263 0.00003906 0.00000527 0.99058914]]로 출력이 되는데 소수점 부분부터 출력이 안되고 저렇게 출력이 되는데 어떻게 해야 수정이 가능할까요??