Training model in Python and Loading into TensorFlow.js – TensorFlow.js p.4




[ad_1]

Welcome to part 4 of the TensorFlow.js series, where we’re going to be working on the challenge of training a model in Python, and then loading that trained model from Python back into your TensorFlow.js application. To start, we need to first train a Python model.

Text tutorials and sample code: https://pythonprogramming.net/loading-keras-model-tensorflowjs-tutorial/

Chat with us on Discord: https://goo.gl/Q9euv3
Support the content: https://pythonprogramming.net/support-donate/
Twitter: https://twitter.com/sentdex
Facebook: https://www.facebook.com/pythonprogramming.net/
Twitch: https://www.twitch.tv/sentdex
G+: https://plus.google.com/+sentdex

Source


[ad_2]

Comment List

  • sentdex
    January 1, 2021

    I feel intimidated by lack of other comments.

  • sentdex
    January 1, 2021

    When I try to make predictions with my model, I get the error Uncaught TypeError: Cannot read property 'length' of undefined. Does anyone have a solution to this?

  • sentdex
    January 1, 2021

    Can you make a tutorial about convert TensorFlow model to the TensorFlow.js web format? I really confused about that

  • sentdex
    January 1, 2021

    Four 20-minute videos and it still can't beat you at pong.

  • sentdex
    January 1, 2021

    Please learn you first before explaining others.

  • sentdex
    January 1, 2021

    Sentsex, the Json dataset you provided contains 6 feature whereas u trained model with 8 features in the previous video, so which of the two parameters are removed here.

  • sentdex
    January 1, 2021

    For the "no server problem/cors" for testing, just go to your folder and use SimpleHTTPServer from python to server in a local webserver for testing "python -m SimpleHTTPServer 8000" it will serve in http://localhost:8000 ez

  • sentdex
    January 1, 2021

    i have some trouble. When i run 'pip install tensorflowjs' Error "Could not find a version that satisfies the requirement tensorflow==1.9.0 (from tensorflowjs) (from versions: )"

    Can you help me?? pls

  • sentdex
    January 1, 2021

    Hi there.
    Thanks for sharing your insights on TF and TFJS.
    Couple of questions I have below. Hope you can help to clarify:

    1. When adding layers to a model, what is the factor that results in the number of layers used, as well as number of input shapes to use between each layer? For instance, for tut #4, a total of 6 inputs are applied to the input layer.

    model.add(Dense(64, activation='relu', input_dim=6)) #for subsequent layers, the inputs will be taken care of

    2. The 4 tutorials switches between letting TF decide on the type of neural network used, vs the explicit use of 'relu' / 'sigmoid'. How does one decide when it is best t o let TF make the call on the appropriate type of NN to use.

    Look forward to your feedback.

  • sentdex
    January 1, 2021

    Here is what i did to use my own model:

    I used a nodejs package that easily allows you to host a folder in your computer in a localhost server. https://www.npmjs.com/package/static-server

    once you have it installed you just need to go the folder where you have all your files in the terminal and run the 'static-server' command.
    Then just change the loadModel line to use your local server E.g. model = await tf.loadModel('http://localhost:9080/tfjsmodel/model.json');

    You should then be able to hit your server on http://localhost:9080/pongai.html

  • sentdex
    January 1, 2021

    First of all thank you for everything when the future will come?

  • sentdex
    January 1, 2021

    Are you going to continue this series?

  • sentdex
    January 1, 2021

    I created a small flask app in 10 lines of code to host the model, I think that is the best way to go.

  • sentdex
    January 1, 2021

    Can you please tell me how to load the model from a local folder… it's been driving me crazy throwing errors continuously

  • sentdex
    January 1, 2021

    Yes, the JSON file represents weights…!

  • sentdex
    January 1, 2021

    Hi, I am training the model with keras python and loading the Json file in my js code. Prediction is working correctly from python code but prediction result is not coming correctly from js.
    Can you tell me the reasons behind this.
    Thank you

  • sentdex
    January 1, 2021

    Firefox and Edge both allow you to make cross origin requests for local files. Chrome doesn't

  • sentdex
    January 1, 2021

    Hey Sentdex, the way you'd tackle the problem with loading the model is by using local server. I use webpack-dev-server and webpack to bundle js code (tensorflow and main.js) into single file and load through the index.html by accessing localhost:8080/index.html . Thus the model is available to the script from localhost:8080/model.json .

    Btw: Love your work. If you struggle with js in future while working on new series or in general, I encourage you to ask me at hyphen.wrex@gmail.com

  • sentdex
    January 1, 2021

    I think Keras disables dropout for testing automatically. But does tfjs do the same? Better set K.set_learning_phase(0) before exporting, right? I think you can also add a hash check for external resources: buzzword "Subresource Integrity".

  • sentdex
    January 1, 2021

    your mugs got more and more crazy through this tutorial

  • sentdex
    January 1, 2021

    cant you just use xammp for hosting the model or is that not what you are going for

  • sentdex
    January 1, 2021

    Thank you sentdex for the kind block of review at workspace. I am very happy to continue an original task. The instruction was excellent.
    McGary

  • sentdex
    January 1, 2021

    Mostly just watching this for the mugs.

  • sentdex
    January 1, 2021

    Dont we need to set ai's flip_table as false before making predictions from our neural net ?

  • sentdex
    January 1, 2021

    How long did it take you to learn machine learning ? Or anything new such as django etc. BTW great tutorials ; )

  • sentdex
    January 1, 2021

    Hey sentdex I was wondering can how about using flask for deploying models locally?

  • sentdex
    January 1, 2021

    Wow. Sentex is on fire.

Write a comment