Skip to content

Getting IndexError: pop from empty list on saving and reading h5/keras model file. #2

@deepjyotiroy079

Description

@deepjyotiroy079

Getting this error after saving model and reading it through streamlit application.

IndexError: pop from empty list
File "/home/bionic/code/nlp-tutorial/lstm-end-to-end/app.py", line 10, in <module>
    model = load\_model('hamlet\_lstm\_model.h5')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/saving/saving\_api.py", line 196, in load\_model
    return legacy\_h5\_format.load\_model\_from\_hdf5(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/legacy/saving/legacy\_h5\_format.py", line 132, in load\_model\_from\_hdf5
    model = saving\_utils.model\_from\_config(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/legacy/saving/saving\_utils.py", line 88, in model\_from\_config
    return serialization.deserialize\_keras\_object(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/legacy/saving/serialization.py", line 495, in deserialize\_keras\_object
    deserialized\_obj = cls.from\_config(
                       ^^^^^^^^^^^^^^^^
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/models/sequential.py", line 375, in from\_config
    model.add(layer)
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/models/sequential.py", line 122, in add
    self.\_maybe\_rebuild()
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/models/sequential.py", line 149, in \_maybe\_rebuild
    self.build(input\_shape)
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/layers/layer.py", line 229, in build\_wrapper
    with obj.\_open\_name\_scope():
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/backend/tensorflow/core.py", line 692, in **exit**
    super().**exit**(\*args, \*\*kwargs)
File "/home/bionic/code/nlp-tutorial/env/lib/python3.12/site-packages/keras/src/backend/common/name\_scope.py", line 61, in **exit**
    name\_scope\_stack.pop()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions