-
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
Provided weight data has no target variable: batch_normalization #755
Comments
Hi |
If that weight is an extra one that is lying around for some reason but is not actually needed, you can call Of course, if the weight is needed, doing this would leave you with a broken model. In that case, as @bileschi said, we'd need to see the original Keras model to determine whether there is a conversion bug. |
@rajeev-samalkha is this issue resolved? If so feel free to close. Thankyou. |
Folks, sorry for delayed response. When I take out Batch Norm layer then it seems to work fine (I had to retrain the model). Is there any difference between Batch norm in tf.keras and tfjs. I have used tensorflowjs.converter utility. The model in itself is quite simple with few Con2D layers interspersed by Max Pool/Dropout. Regards |
TFJS BatchNorm maintains 4 up to weights: https://github.com/keras-team/keras/blob/master/keras/layers/normalization.py#L93 I wonder if tf.keras is saving additional tensors, possibly for optimization or related to the momentum for training? Looking at the tensorflow/keras implementation, I see that it is somewhat more complex: including a 'fused' batch-norm implementation that reaches into c. Can you list out the weights in your model from the python code? |
Do you need weights for all the layers or just BatchNorm one. |
Just the names and sizes of the batch_norm related weights should be fine.
No need to provide the actual values.
…On Wed, Oct 10, 2018 at 10:51 AM rajeev-samalkha ***@***.***> wrote:
Do you need weights for all the layers or just BatchNorm one.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#755 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAhZTn53dfvl1D88ywKN59zRuoDWERpgks5ujglrgaJpZM4XFl_7>
.
--
Stan Bileschi Ph.D. | SWE | bileschi@google.com | 617-230-8081
|
I get the same error while loading a keras converted model on browser. Note: Some of my converted model tend to work fine on browser having embeddings in it, but sometimes this error shows up. @bileschi @davidsoergel kindly post a proper fix for this issue. |
Same error here, Someone please help. tfjs@0.13.0:2 Uncaught (in promise) Error: Provided weight data has no target variable: conv2d/kernel |
Folks I think I found why we are getting this error. The error can happen for any layer. Steps to reproduce the error:
It seems every layer name changes in model.json file (it will be different than model.summary name). For example, one of the layer in my model was 'conv2d_6' but it got named as 'conv2d_6_2' when I loaded the model twice. But it seems actual weights (assuming in shard file) still expect 'conv2d_6 in my case. So till we get a fix, pls make sure you load your model only once before doing tfjs conversion. Hope this helps. |
I have tried that too by loading the model exactly once but still, the same error prevails. |
Not sure if this helps, but when I converted my h5 model using the python code modelk = load_model('./input/model.h5') I would receive the following error:
But if I convert the h5 model using the tensorflowjs_converter command line tool my tfjs json model file will load without any problems. |
model summary
error
|
@demohi Can you try using setting the await tf.loadModel(`file://${path.join('xxx', 'model.json')}`, false); Also, this might be a bug in |
@caisq Thank you for your reply. It works. you can convert this keras model to fix the bug. |
@demohi I'm looking into this issue now. It seems the cause to do with the following fact:
This is the reason why the weight loading fails and you get the error. Can you tell me a little about how the model is saved from Python side? Is it possible that there are multiple instances of the model existing in Python memory? I think we need to fix this issue regardless of what happens on the Python side, as Python Keras / TensorFlow can load this sort of model correctly. But I just want to understand the conditions under which this kind of name mismatches happen. Thanks. |
I use the colab to train this model with keras.
|
@demohi At the risk of asking too much, I wonder whether you could try running the same code but from a Python file (or reset the state of the CoLab kernel and run the code from scratch, making sure that each code block is run only once.) I expect the name mismatch to disappear in those cases. Again, don't feel obliged to try that. But if you do have time to try it and let me know, it would be wonderful. We'll work on a fix in the meantime. |
I am facing the same issue. It appears to happen when I run the |
Same error with
could someone fix it? |
+Shanqing Cai <cais@google.com>
…On Mon, Feb 25, 2019 at 11:44 AM SHAFAY HASEEB ***@***.***> wrote:
Same error with
Error: Provided weight data has no target variable: Conv1_1/kernel
could someone fix it?
I am converting mobilenet_v2 to tensorflow js for browser classification
task
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#755 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABDLzX1QPJKhfwe3rYYlhN0sayKPxhwFks5vRBLlgaJpZM4XFl_7>
.
|
This helped me solve the problem. I had to run my google colab again after cleaning the runtime. I made sure i execute each code block once and then i converted the model using It is working perfectly fine in the browser now :) |
I was experiencing this in the following scenario:
This might be obvious, but the issue was that in the call to The underlying
To solve my version of the issue (where there was at some point a copy of the same model and I loaded a new one), you can reset the
|
The way I solved the same problem (provided weight data has no target variable conv1_1/kernel) is by cleaning all output and cache of my jupyter notebook, loading model (model = load_model('./tf_files/keras/modelKeras2.h5')) and converting with tfjs (tfjs.converters.save_keras_model(model, './tfjsModelConverted/model6') ). Hope it helps... |
This particular way worked for me but instead of using the
functionality I used the tensorflow API to keras as clearing the seesion by directly using keras module throws an error with tensorflow. The following is what I used
|
Here is how i converted the model using google colab (ipython)... Once you have saved the entire model as a h5 file, upload it to colab and run the script to generate the tfjs model.
Restart runtime after installationimport kerasimport os import tfjsimport tensorflowjs as tfjs load modeltf.compat.v1.disable_eager_execution() create directory!mkdir model convert modeltfjs.converters.save_keras_model(model, '/content/model') !zip -r model.zip /content/model download and verify |
@anilsathyan7 thank you , closing this issue. |
To get help from the community, check out our Google group.
TensorFlow.js version
0.13
Browser version
Chrome Version 69.0.3497.100
Describe the problem or feature request
I converted a Keras model to tfjs using python utility with no errors. But when I try to load the model in tfjs, I get the following error:
Code to reproduce the bug / link to feature request
Running it on local machine.
model = await tf.loadModel(<path_to_model.json>)
The text was updated successfully, but these errors were encountered: