Home > other >  Why keras image recognition recognition results probability is 100% and 0%
Why keras image recognition recognition results probability is 100% and 0%

Time:11-21

 
The model=Sequential ()

Model. The add (
Convolution2D (
32, 5, padding="same", input_shape=(224224, 3), the activation="relu
")
)
Model. The add (
MaxPooling2D (
(2, 2), padding="same"
)
)
Model. The add (
Convolution2D (
64, 5, padding="same", activation="relu
")
)
Model. The add (
MaxPooling2D (
(2, 2), padding="same"
)
)
Model. The add (
Convolution2D (
128, 5, padding="same", activation="relu
")
)
Model. The add (
MaxPooling2D (
(2, 2), padding="same"
)
)
Model. The add (Flatten ())
Model. The add (
Dense (
In 128, the activation="relu"
)
)
Model. The add (
Dense (
In 64, the activation="relu"
)
)
Model. The add (
Dense (
10 and the activation="softmax"
)
)
Model.com from running (
Adam (lr=0.0001), loss="categorical_crossentropy",
The metrics=[" accuracy "]
)

Img_generator=image. ImageDataGenerator (
Rescale 1.0/255=
)

Train_img=img_generator. Flow_from_directory (
"ANIMALS",
Target_size=(224224),
Shuffle=True,
Seed=54,
)

Name="bear", "cat", "cheetah", "cow", "like crocodiles", "deer", "dogs" and "elephant", "giraffe", "goat"]
Img_arr=image. Load_img (" 1. JPG ", target_size=(224224));
Img_arr=image. Img_to_array (img_arr)
Img_arr=np. Expand_dims (img_arr, axis=0)

The pre=model predict (img_arr)



Loss function is categorical_crossentropy,
Then use the predictions of a picture is always:

Prediction probability or 100%, or 0%

CodePudding user response:

I am not here oh
  • Related