0

Im trying to load the saved weight from my model so that i can use it to make predictions But i keep getting this error AttributeError: 'NoneType' object has no attribute 'predit_classes'

I know that the code i have tried is mainly for model used like this: model = Sequential() but i dont know how else to go about it.

 test_model=model.load_weights('second_try.h5')
img = load_img('0008_00_00_01_219.jpg',False,target_size=(150,150))

x=img_to_array(img)
x = np.expand_dims(x, axis=0)
img_class = test_model.predict_classes(x)
print ("Class:", img_class)
1
  • I don't think model.load_weights returns a value -- in which case the error message describes exactly what's going on. Commented May 13, 2019 at 3:28

1 Answer 1

1

load_weights does not return a model (it returns nothing), you already have a model in the model variable, so you just need to do:

model.load_weights('second_try.h5')
img = load_img('0008_00_00_01_219.jpg',False,target_size=(150,150))

x=img_to_array(img)
x = np.expand_dims(x, axis=0)
img_class = model.predict_classes(x)
print ("Class:", img_class)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.