tensorflow / tfjs

A WebGL accelerated JavaScript library for training and deploying ML models.
https://js.tensorflow.org
Apache License 2.0
18.3k stars 1.91k forks source link

Problem converting Keras Models into Layers API format models to use with tensorflow.js #1431

Closed kostadin-t closed 4 years ago

kostadin-t commented 5 years ago

I have a Problem converting Keras Models into Layers API format models to use with tensorflowjs

I use the command:

$ tensorflowjs_converter --input_format keras kerasModels/vgg16_weights_tf_dim_ordering_tf_kernels.h5 convertedModels/

I get an error "KeyError: Can't open attribute (can't locate attribute 'keras version')"

Here is an image of the error log: image

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

Browser version

Describe the problem or feature request

Code to reproduce the bug / link to feature request

mickey0425 commented 5 years ago

Did you solve the problem? I have same problem too

caisq commented 5 years ago

@kostadinakis @mickey0425 I tried reproducing this error by saving an .h5 file from keras.applications.vgg16.VGG16 and using the command tensorflowjs_converter --input_format keras vgg16.h5 converted_vgg16 and it worked. My version of tensorflowjs_converter is as follows:

tensorflowjs 0.6.7

Dependency versions: keras 2.2.4 tensorflow 1.12.0

In order to help me debug this further, can you let me know

  1. The output of tensorflowjs_converter --version
  2. How your vgg16_weights_tf_dim_ordering_tf_kernels.h5 was created.