Kerasで「AttributeError: 'NoneType' object has no attribute HOGEHOGE」

エラー

Kerasで重みを読み込む時に以下のエラー。

model_50 = model_50.load_weights('/host/weights/weights.013-7.248.hdf5')

# AttributeError: 'NoneType' object has no attribute 'load_weights'

NoneType。。。

print(type(model_50))

# <class 'NoneType'>

解決策

代入はしなくて以下のようにするだけでmodel_50には代入される。

model_50.load_weights('/host/weights/weights.013-7.248.hdf5')

うん。大丈夫。

print(type(model_50))

# <class 'keras.engine.training.Model'>