I have always been bad at calculus. I think it all started with I was locked into a good grade in college and I stopped going to class. When my next calc class started I had a trash teacher and have been digging myself out ever since. Because of this, I haven’t been able to figure out what the heck is going on with gradients while working with TFv2.
I would see that we would have 4 x 4 equal to 16 but when we did a gradient on that same thing we would get 8. So, here is my attempt to write this out and explain what is going on. I also have a slightly longer Colab Notebook on GitHub.
First, we have the equation and . We then try and find the derivate .
If you know calculus, which it appears EVERY web site I go to assumes you do, you can see that to find this derivative you use the power rule. This states that you can convert to
Using that, we can see becomes and since we get
Now, to the second example that uses a cube. , , and is . This then gives use and using $x = 2$ we get
Hopefully, this clears up what is going one. If not, you can just call me a dummy like I am sure everyone else already does when I try and do calculus.
Check out my working site: http://bet.eckronsoftware.com!
Good new: It works. Bad news: It doesn’t work on a mobile browser. I have a GitHub Ticket (1586) open hoping that it will be cleared up. The issue is wild though, using the same JS library and the same model in the same bucket in the same cloud returns different values if you use a phone.
Anyway, here is how I got everything up and running.
First, I installed TensorFlowJS in my Google Colab notebook. I was then able to use that to create a save
Second, I created another bucket like I did in my previous post. In that bucket I uploaded my plain HTML file and then a folder for my scripts. In the scripts folder I added my model.
Third, in my HTML file I needed to call out to a different server to load TensorFlowJS :
<script src=”https://cdn.jsdeliver.net/npm/@email@example.com/tf.min.js” />
Finally, I needed to figure out what in the world a Promise in JS is. Turns out, it is just an async return type similar to a Task in .NET. Once I got this loaded on start up and then called the model on a click I was good to go.
In the near future, I am going to clean up this site as well as allow the user to select 2 teams and see what the model things will happen. Stay tuned!
After completing my DevPost project and hearing that Iowa has legalized sports betting I decided I should take my model out of Google Colab and into the magical cloud.
My plan was to follow a few web sites and upload my model. This didn’t go well. As listed in the GitHub issue at the bottom. There is an issue with TFv2 and the AI-Engine.
But, here are the steps I went through to get to a place where once a bug fix is in place I will be up and running.
First, I had to create a model that would work. My assumption that my original h5 file was good enough was wrong. I needed to use the ‘Saved_Model’ method. Well, in TFv2 this was moved from contrib to experimental. Once this was cleared up I created the model and exported it from my Colab notebook.
Second, I created a Cloud Bucket to host my model. This was straight forward.
Third, I needed to test my model. I had to create a text file that would host my input parameters so I could test locally. Then, using the gcloud command line I called ai-platform and got an error message. It turns out that the way the model was built wasn’t compatible with how AI-Engine expects.
Finally, I just created the GitHub issue and asked around in my Google slack channels. It turns out it is an open issue. The real problem is that since this is between the cloud and TF I am not sure who blinks first and has to change it.
Feel free to watch the issue to see if/when this gets figured out.
GitHub Issue: https://github.com/tensorflow/tensorflow/issues/28708