TransWikia.com

I tried loading my saved .h5 model and predicting with that model, i'm getting error list index out of range

Data Science Asked by Nithin Reddy on January 3, 2021

I saved my keras model into .h5 format. Again I’ve loaded that .h5 file into my colab and tried to predict with that model.
model.save("/content/drive/My Drive/Datasets/sentiment_analysis.h5")

from keras.models import load_model
loaded_model = load_model("/content/drive/MyDrive/Datasets/sentiment_analysis.h5")
loaded_model.predict("i love machine learning and google")

It’s giving error list index out of range.

IndexError: list index out of range

One Answer

Try these:

  1. import everything from tensorflow keras API.
  2. tf.keras.models.load_model("./saved_models/our_model.h5", compile=False) (make sure you have model and weights both in the file)

Answered by Akash on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP