修正prediction=model.predict_classes(x_test_normalize)

 原程式碼:prediction=model.predict_classes(x_test_normalize) 

出現錯誤:AttributeError Traceback (most recent call last)

Cell In[62], line 1
----> 1 prediction=model.predict_classes(x_test_normalize)

AttributeError: 'Sequential' object has no attribute 'predict_classes'

修正成這樣就好了
import numpy as np

# Assuming you have defined and compiled your Keras model
# model = Sequential() # Your model definition
# model.compile(...) # Your model compilation

# Assuming you have normalized test data `x_test_normalize`

# Use the predict method to get probability scores
probabilities = model.predict(x_test_normalize)

# Use np.argmax to find the predicted class indices
predicted_classes = np.argmax(probabilities, axis=1)

评论

此博客中的热门博文

修正input_img_data = np.random.random((1, 150, 150, 3)) * 20 + 128.

緣起