question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provided weight data has no target variable: batch_normalization

See original GitHub 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:

tfjs@0.13.0:2 Uncaught (in promise) Error: Provided weight data has no target variable: batch_normalization_1_2/gamma
    at new t (tfjs@0.13.0:2)
    at loadWeightsFromNamedTensorMap (tfjs@0.13.0:2)
    at t.loadWeights (tfjs@0.13.0:2)
    at tfjs@0.13.0:2
    at tfjs@0.13.0:2
    at Object.next (tfjs@0.13.0:2)
    at i (tfjs@0.13.0:2)

Code to reproduce the bug / link to feature request

Running it on local machine. model = await tf.loadModel(<path_to_model.json>)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
rajeev-tbrewcommented, Oct 25, 2018

Folks

I think I found why we are getting this error. The error can happen for any layer. Steps to reproduce the error:

  1. Load the model in tensorFlow using tf.keras.
  2. Load the same model again (basically load the model more than once).
  3. Use tfjs.converters to convert keras model and you get this 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.

3reactions
stephenrt42commented, Nov 24, 2018

Not sure if this helps, but when I converted my h5 model using the python code `import tensorflowjs as tfjs from keras.models import load_model

modelk = load_model(‘./input/model.h5’)
tfjs.converters.save_keras_model(modelk, ‘./output/’)`

I would receive the following error:

errors.ts:48 Uncaught (in promise) Error: Provided weight data has no target variable: dense_1_7/kernel at new t (errors.ts:48) at loadWeightsFromNamedTensorMap (container.ts:190) at t.loadWeights (container.ts:759) at models.ts:285 at index.ts:79 at Object.next (index.ts:79) at i (index.ts:79)

But if I convert the h5 model using the tensorflowjs_converter command line tool my tfjs json model file will load without any problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught (in promise) Error: Provided weight data has no ...
Unfortunately, when I try to load the JSON model I get this error: Uncaught (in promise) Error: Provided weight data has no target...
Read more >
How to Transform Target Variables for Regression in Python
It will prepare the transform of the target variable using the same training data used to fit the model, then apply that inverse...
Read more >
Batch Normalization in practice: an example with Keras and ...
In this article, we will focus on adding and customizing batch normalization in our machine learning model and look at an example of...
Read more >
HyperParameter Tuning, Batch Normalization - Kaggle
The data is provided as file named 'data.csv'. ... 'df' and assign it to variable 'X'; Extract target variable 'traget' and assign it...
Read more >
The Effect of Batch Normalization on Deep Convolutional ...
the use of variance-preserving weight initialization, as well ... The test set is a set of data that is not used during training,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found