You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chrome Version 83.0.4103.97 (Official Build) (64-bit)
Summary
I have a problem in loading a trained model that was developed using Python and TensorFlow Keras into TensorFlow.js.
Procedure
The model was developed using Python, TensorFlow, and Keras using: model.fit(...) model.save('./model_python_tf_keras.h5)
This model is attached.
I then converted this Keras model into a TensorFlow.js model using: $ tensorflowjs_converter --input_format=keras ./model_python_tf_keras.h5 ./model_js
The resulting folder is attached.
Problem
I get a problem when I try to load the new model in an HTML document (index_min.html is attached) using the following Javascript code: model = await tf.loadLayersModel('http://localhost:63342/powem_meters/model_js/model.json');
The error message is: Uncaught (in promise) Error: Provided weight data has no target variable: bidirectional/forward_lstm/lstm_cell_1/kernel
As a result, I am not able to use my model in a Javascript program.
Notes
I have tried to save the model directly from Python using: tfjs.converters.save_keras_model(model, "./model_js")
And I tried running the tensorflowjs_converted using tf version 1.4.0 and tfjs version 1.2.6. But I keep getting the same error.
I have also noticed that the above procedure works for a simple fully-connected model. However, my model is not a custom one. The model definition code is: model = Sequential() model.add(Embedding(num_tokens+1, 32, input_length=max_seq_length)) model.add(Bidirectional(LSTM(latent_dim, input_shape=(None,num_tokens), return_sequences=True, dropout=0.1, recurrent_dropout=0.3), merge_mode='concat')) model.add(Bidirectional(LSTM(latent_dim, dropout=0.1, recurrent_dropout=0.3), merge_mode='concat')) model.add(Dense(output_data.shape[1], activation='softmax')) model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
Details
My environment is as follows:
OS: Ubuntu 20.04
Python version 3.8.2
tensorflow 2.2.0rc4
tensorflowjs 2.0.0 files.zip
The text was updated successfully, but these errors were encountered:
TensorFlow.js version
2.0.0
Browser version
Chrome Version 83.0.4103.97 (Official Build) (64-bit)
Summary
I have a problem in loading a trained model that was developed using Python and TensorFlow Keras into TensorFlow.js.
Procedure
The model was developed using Python, TensorFlow, and Keras using:
model.fit(...)
model.save('./model_python_tf_keras.h5)
This model is attached.
I then converted this Keras model into a TensorFlow.js model using:
$ tensorflowjs_converter --input_format=keras ./model_python_tf_keras.h5 ./model_js
The resulting folder is attached.
Problem
I get a problem when I try to load the new model in an HTML document (index_min.html is attached) using the following Javascript code:
model = await tf.loadLayersModel('http://localhost:63342/powem_meters/model_js/model.json');
The error message is:
Uncaught (in promise) Error: Provided weight data has no target variable: bidirectional/forward_lstm/lstm_cell_1/kernel
As a result, I am not able to use my model in a Javascript program.
Notes
I have tried to save the model directly from Python using:
tfjs.converters.save_keras_model(model, "./model_js")
And I tried running the tensorflowjs_converted using tf version 1.4.0 and tfjs version 1.2.6. But I keep getting the same error.
I have also noticed that the above procedure works for a simple fully-connected model. However, my model is not a custom one. The model definition code is:
model = Sequential()
model.add(Embedding(num_tokens+1, 32, input_length=max_seq_length))
model.add(Bidirectional(LSTM(latent_dim, input_shape=(None,num_tokens), return_sequences=True, dropout=0.1, recurrent_dropout=0.3), merge_mode='concat'))
model.add(Bidirectional(LSTM(latent_dim, dropout=0.1, recurrent_dropout=0.3), merge_mode='concat'))
model.add(Dense(output_data.shape[1], activation='softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
Details
My environment is as follows:
OS: Ubuntu 20.04
Python version 3.8.2
tensorflow 2.2.0rc4
tensorflowjs 2.0.0
files.zip
The text was updated successfully, but these errors were encountered: