-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Completely wrong infer result in tf.keras and tf.js #784
Comments
@theangels Thanks for reporting this issue. I suspect that the difference may have more to do with the model (json) than with the weights. So can you simply share the model JSON with us? In keras, this can be obtained with model.to_json(). That way we won't have to worry about sending large files. |
OK, there are the model define JSON files: Keras model
tf.js model
|
Thanks @theangels , for sending over the model JSONs. This is what I did
The output I got from Python is: The output I got in tfjs is: So the two results are not that far apart, especially if we focus on the largest (3rd) value, which is about 0.86 - 0.87. The difference I got is definitely not as big as the difference you showed above. So I think the debugging steps for you is: print out the values of the weights in Python and JS and compare them. In Python, you can do something like print(model.get_weights()[0]) In JS, you can do model.getWeights()[0].print(); I suspect that there may be something messed up during your weight serving / downloading process. The situation feels very similar to another issue: #776 |
Thanks @caisq .I'm so sorry for provide the wrong model json before, because I trained another model. And the 'voice.txt' file has 102400 values (include '0' value), you can load values by using it
keras model
And I try to follow you to check the weights, there are the results. If you need my weight file or model file or hole project, I also can provide it. pythontf.js |
Thanks @caisq , I upgrade tensorflow version to 1.11.0 version, tfjs-converter to 0.6.2. And I retrain the 7-voice model by using the same dataset as before, try to infer by using tensorflowjs in Web application. I found it works. |
To get help from the community, check out our Google group.
TensorFlow.js version
TensorFlow version: 1.10.1
tensorflowjs_converters version: 0.6.1
TensorFlow.js version: script(src='https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest')
Browser version
Chrome 69.0.3497.100
Describe the problem or feature request
I trained a Keras Sequential model in python, and transofrm it to tf.js model by using tensorflowjs_converters. But I found the infer result are completely wrong in python and tf.js. There is the infer code.
Python infer
tf.js infer
var "intArray" are the input data and it's shape is [100.1024], dtype is int32(I transformed it to float32 in data process)
And there is the model:
I use the same input data, and here are the infer result
Python infer
tf.js infer
Models
The model files are more than 10MB, so I use SFX. If you want to use it, just change the name, such as
“model2.002.zip” to "model2.zip.002"
tf.js model
model2.002.zip
model2.003.zip
model2.004.zip
model2.005.zip
model2.001.zip
keras model
keras.001.zip
keras.002.zip
keras.003.zip
keras.004.zip
keras.005.zip
input file
voice.txt
Code to reproduce the bug / link to feature request
N/A
The text was updated successfully, but these errors were encountered: