Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught (in promise) Error: Provided weight data has no target variable: block1_conv1_2/kernel

I am new to machine learning and I was following this blog on how to write a model with mobilenet.

I managed to convert the .h5 file model and tried to implement it on my web app.

Unfortunately, when I try to load the JSON model I get this error:

Uncaught (in promise) Error: Provided weight data has no target variable: block1_conv1_2/kernel.

Screenshot of the error on a browser

I converted the .h5 model in the command line like so:

tensorflowjs_converter --input_format keras model.h5 ConvertedModel/

The code to load the model in the browser, I followed this blog

let model;
async function loadModel(name) {
  $(".progress-bar").show(); 
  model = undefined;
  model = await tf.loadModel(`ConvertedModel/model.json`);
    $(".progress-bar").hide();
}

To see the code of the model please refer to the blog link. But below is a screenshot of how the model is compiled. Model compilation

Dependencies:

  • Tensorflow 1.13.1
  • Python 3.6.0
  • tensorflowjs 1.0.1

Any help to fix this would be appreciated. Thank you so much.

like image 798
Rstynbl Avatar asked Mar 22 '19 08:03

Rstynbl


1 Answers

It seems you've encountered this error where an extra suffix has been added to some of your weights.

You can work around this issue by manually removing these extra suffixes from your model.json:

block1_conv1_2/kernel 

should instead be:

block1_conv1/kernel

The 'Error in clip' bug has now been fixed so I'm not too sure why you've received this one, but once again you can work around this by manually editing the model.json, and changing every instance of:

{"type":"ndarray", "value":6}

to

6
like image 170
BMcFadyen Avatar answered Oct 14 '22 17:10

BMcFadyen