-
Notifications
You must be signed in to change notification settings - Fork 31
xor training example #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
nice! looks good!
We should add this as one of the tutorials in the ml5 website too |
This looks great! You can make predict a little shorter:
So in general, with the structure of your program, you used You can likely remove some of the memory management stuff if you create your dataset Tensors ( Learning rate seems fine. In general, learning rate is proportional to the range of your dataset. It's really important to normalize dataset between 0=>1 or -1=>1, in fact much of the initializer mathematics relies on this so your model doesn't explode. In your case, your data is already normalized because it's learning a binary transformation. Regarding epochs, this is really up to you. If you want to make an interactive application, I would set epochs to 1 so you can see new predictions between each pass through the whole dataset. This is really up to you, though. Use The only complication with
Hope this helps. Let me know if I can clarify anything. |
One more thing I noticed, you don't need inputShape on layers 2+ (it can be computed for you!) You can also shorten your code a little (totally optional):
|
Updating this in preparation of YouTube tutorial. Changes thanks to feedback from @nsthorat. I think if we are to create generic `NeuralNetwork` or `Classifier` classes in ml5, a lot of the work will inevitably involve data helper classes so that the end user can work with vanilla arrays and tensors are all created and managed internally by ml5.
This example works!
https://shiffman.github.io/Tensorflow-JS-Examples/01_XOR/
I am planning to recreate my XOR Coding Challenge in a video tutorial with the layers API. @nsthorat @dsmilkov @cvalenzuela @yining1023 feel free to take a look at the code in case you have any feedback!
This example at the moment is written in a slightly strange way as I'm experimenting with ideas for wrapping the layers API into new classes for ml5:
NeuralNetwork
(likely not the same I will use) andBatch
. When I make a tutorial I will just walk through the steps without breaking things out into separate classes. And then eventually I'll make an even simpler ml5 tutorial?The things I'm not super sure about:
tidy()
vs. individualdispose()
draw()
.dataSync()
vsdata()
(in conjunction with an animation loop).This is obviously a totally trivial example -- The XOR problem is one that helps me think through and learn how this stuff works. . so hopefully it's useful?
The text was updated successfully, but these errors were encountered: