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]
I feel intimidated by lack of other comments.
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?
Can you make a tutorial about convert TensorFlow model to the TensorFlow.js web format? I really confused about that
Four 20-minute videos and it still can't beat you at pong.
Please learn you first before explaining others.
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.
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
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
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.
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
First of all thank you for everything when the future will come?
Are you going to continue this series?
I created a small flask app in 10 lines of code to host the model, I think that is the best way to go.
Can you please tell me how to load the model from a local folder… it's been driving me crazy throwing errors continuously
Yes, the JSON file represents weights…!
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
Firefox and Edge both allow you to make cross origin requests for local files. Chrome doesn't
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
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".
your mugs got more and more crazy through this tutorial
cant you just use xammp for hosting the model or is that not what you are going for
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
Mostly just watching this for the mugs.
Dont we need to set ai's flip_table as false before making predictions from our neural net ?
How long did it take you to learn machine learning ? Or anything new such as django etc. BTW great tutorials ; )
Hey sentdex I was wondering can how about using flask for deploying models locally?
Wow. Sentex is on fire.