4

While executing the following code embedded in html using WAMP stack

const model = tf.loadLayersModel('js/model.json');

I encounter the following errors in chrome

> Uncaught (in promise) TypeError: Failed to fetch

> platform_browser.ts:28 GET http://localhost/poemgenerator/js/group1-shard3of22.bin net::ERR_EMPTY_RESPONSE

> Uncaught (in promise) TypeError: Failed to fetch

I have all the group1-shard__of22.bin present at the mentioned location

During every run of the code, the ERR_EMPTY_RESPONSE is shown on different files.

The tfjs loaded using

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>


PS:

While executing the code IDM starts downloading all the group1-shard__of22.bin files

I The model being loaded was created in python and is a tf.keras model. which has been converted using tfjs converter


Update :

I used the replaced the above code with

async function predict(){
  const model = await tf.loadLayersModel('js/model.json');
  model.summary()
}

And also removed IDM but it showed another errors :

> errors.ts:48 Uncaught (in promise) Error: Provided weight data has no target variable: lstm_3/lstm_cell_3/kernel

> (index):68 Uncaught TypeError: model.summary is not a function

1 Answer 1

1

Since Tensorflow works best in an asynchronous way, you should use an async function with await when loading the model:

async function predict(){
  const model = await tf.loadLayersModel('js/model.json');
  // do prediction
}
Sign up to request clarification or add additional context in comments.

5 Comments

I encountered the following error while using the above code : errors.ts:48 Uncaught (in promise) Error: Provided weight data has no target variable: lstm_3/lstm_cell_3/kernel
Please, your first question was ok, but keep your post to one question. And do some research before you ask, I found the solution by just googling your error. Here you can find the answer: stackoverflow.com/questions/55295671/…
I had already googled it, and found this one too, but it didn't work for me.
I have the following error: Error: Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.
I think this has to do with something else. Please ask it in a new question with the provided code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.