Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in model load weights #19289

Closed
lenlen opened this issue May 15, 2018 · 1 comment
Closed

Error in model load weights #19289

lenlen opened this issue May 15, 2018 · 1 comment
Assignees

Comments

@lenlen
Copy link

lenlen commented May 15, 2018

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): N/A
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • TensorFlow installed from (source or binary): from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • TensorFlow version (use command below): from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • Python version: from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • Bazel version (if compiling from source): from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • GCC/Compiler version (if compiling from source): from nightly-devel-gpu-py3 and nightly-gpu-py3 docker images
  • CUDA/cuDNN version: 9.0
  • GPU model and memory: tesla k80
  • Exact command to reproduce: N/A

Describe the problem

Running with nightly (both nightly-devel-gpu-py3 and nightly-gpu-py3) is not possible load weights on the keras model.
In the example belowe I have saved the weights, they are saved correctly in the file system and then I have tryed to load them, but I've got an error.

Source code / logs

Here the snippet:

import tensorflow as tf
from tensorflow import keras as ks


def main():
    input_rgb = ks.layers.Input(shape=(1, 5, 5, 3), name="input_rgb")
    x = ks.layers.Dense(1, activation='relu', name="Dense_1")(input_rgb)
    x = ks.layers.Dense(1, activation='sigmoid', name="sigmoid")(x)
    model = ks.models.Model(inputs=[input_rgb], outputs=[x])
    model.compile(
        loss={'sigmoid': 'binary_crossentropy'},
        optimizer=tf.keras.optimizers.Adam())
    model.save_weights('/tmp/test_weights.h5')

    model.load_weights('/tmp/test_weights.h5', by_name=True)


if __name__ == "__main__":
    main()

And here the output:

2018-05-15 09:56:21.404382: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open /tmp/test_weights.h5: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
@allenlavoie allenlavoie self-assigned this May 15, 2018
@allenlavoie
Copy link
Member

You can safely ignore the warning. It does a test to see if the file is in TensorFlow format, sees that it isn't, and loads using HDF5.

I'll put together a change to get rid of the warning anyway. Thank you for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants