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.

Uncaught TypeError: model.predict is not a function

See original GitHub issue

Hi,

I have imported a pre-trained keras model via json file. Find my javascript below:

 var a = (form.input1.value);
    $.post('http://127.0.0.1:5000/',{"text":a},function(response)
    {
        console.log('response: ',response);
        var arr=response;
        const model=tf.loadModel('./json/model.json');
        console.log(model.predict(arr))

    });

but I am getting the error that Uncaught TypeError: model.predict is not a function.

Please help this issue.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
nsthoratcommented, Apr 10, 2018

loadModel returns a promise so you have to await it. Try this:

 var a = (form.input1.value);
    $.post('http://127.0.0.1:5000/',{"text":a}, async function(response)
    {
        console.log('response: ',response);
        var arr=response;
        const model= await tf.loadModel('./json/model.json');
        console.log(model.predict(arr))

    });
0reactions
kallolscommented, Apr 12, 2018

@nsthorat @dsmilkov A big thanks to all of you. Its working fine as I wanted. I am closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "model.predict is not a function" (tensorflow.js)?
But i got one) And it tells TypeError: model.predict is not a function . Why is it happened? i use this link as...
Read more >
Model.predict() not a function - Google Groups
I am trying to do image segementation of cell images to identify cells in tensor flow using data provided in ...
Read more >
TypeError: model.predict is not a function Code Example
Answers related to “TypeError: model.predict is not a function”. Uncaught TypeError: $ is not a function · Syntax Error: TypeError: this.getOptions is not...
Read more >
Problem with TensorFlow load model - Libraries
Hey, first time I'm using TensorFlow.js and I got a problem: I trained a model and saved it on my computer (2 files:...
Read more >
Unable to Predict the custom trained mobilenet in browser ...
async function initialize() { try{ model = await tf. ... Uncaught (in promise) TypeError: Cannot read property 'backend' of undefined at ...
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