farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 845 forks source link

AttributeError: 'NoneType' object has no attribute 'predict' #214

Closed Annztt closed 7 years ago

Annztt commented 7 years ago

I saved model: model.save_weights('model/s2s_model.h5') and i can load it: model = model.load_weights('model/s2s_model.h5') but have error in predict: AttributeError: 'NoneType' object has no attribute 'predict' how can i fix that?

Ogoenkado commented 6 years ago

Hi Annztt

I'm having this issue now and was wondering how you managed to resolve it given that you closed this issue the very next day?

Thanks, Ogo

Ogoenkado commented 6 years ago

Stack overflow to the rescue! I made the same mistake as you :').

"Another common reason you have None where you don't expect it is assignment of an in-place operation on a mutable object. For example:

mylist = mylist.sort() The sort() method of a list sorts the list in-place, that is, mylist is modified. But the actual return value of the method is None and not the list sorted. So you've just assigned None to mylist. If you next try to do, say, mylist.append(1) Python will give you this error."

Questdream commented 3 years ago

Your problem happens when you load weights: model = model.load_weights('model/s2s_model.h5') model.load_weights('model/s2s_model.h5') return a None So, instead just runmodel.load_weights('model/s2s_model.h5') in that cell.