Group Abstract Group Abstract

Message Boards Message Boards

IoT Neural Net Machine Learning Instant API

I tested the Classify algo's on a big data set of text message conversations between users and business IoT devices. The Neral Net was fantastically more accurate than the rest.

It took a long time to run, which is fine. The problem I am facing is:

After uploading it to the cloud and creating API access, the API is slower than dirt. It times out even. However, when I classify samples in the notebook it is lightning fast as always.

My code:

Quiet[CloudDeploy[
  APIFunction[{"text" -> 
     "String" -> "Please turn off the lights at 10pm."}, 
   Get["BtNeuralNetwork"][#text] &], 
  Permissions -> "Public"]]

I used "CloudGet" and the result was even slower. Not sure how that makes any sense.

I even tried compressing it before deploying using:

With[{c = Compress[c]}, 
 CloudEvaluate[Put[Uncompress[c], "BtNeuralNetwork"]]]

Nothing really makes a difference. The API is slow in responding. When I was using Markov it replied instantly on notebook and cloud. The neural net is same speed on notebook but not cloud. Obviously, "BtNeuralNetwork" is just the arbitrary name I gave the model. The fact that it responses correctly "when" it does respond tells me it's working. I just can't figure out how to speed up the response time.

POSTED BY: David Johnston
7 Replies

Any updates? I am still stumped.

POSTED BY: David Johnston

I changed the code to this:

Quiet[CloudDeploy[
  APIFunction[{"text" -> 
     "String" -> 
      "Why are you texting this to me?"}, {Get[
       "BtNeuralNetwork"][#text],
     fileCount = FileByteCount["BtNeuralNetwork"],
     loadTiming = 
      Median[First@AbsoluteTiming[Get["BtNeuralNetwork"]]]} &], 
  Permissions -> "Public"]]

Here is the API response I get:

{"REQUEST FOR INTENT", 134214106, Median[9.905657]}
POSTED BY: David Johnston
Posted 10 years ago
POSTED BY: Joel Klein

Yes, I trained the data on my Macbook Pro and then PUT it locally and then also PUT it in cloud. When I GET it locally or GET it from Cloud, it performs lightning fast on my laptop. The problem only happens when I ask it via API.

POSTED BY: David Johnston
POSTED BY: David Johnston

Is it possible to post a complete code including Classify and data? If not data - just Classify referring to a training set (with a byte size of dataset mentioned) ? I do not understand where do you train your net (desktop or cloud). The more complete the discription of the problem the better it is to go about it.

POSTED BY: Sam Carrettie

I also tried finding a way to not "Get" the model every time and use a variable. However, I spent many hours and found no good tutorials or documentation on writing a simple if statement for testing whether the model we loaded already or not.

I tried:

If[BtNearalNetwork=="",Get["BtNeuralNetwork"][#text],BtNeuralNetwork[#text]]
POSTED BY: David Johnston
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard