Search code examples
tensorflowsiddhistream-processingwso2-streaming-integrator

How to pass parameters to tensorflow's predict function in siddhi?


What parameters are passed to the predict function? Is there any documentation available for using siddhi's tensorflow plugin?

While there is a pbtxt model as part of the sample, that itself is very vague, with no background on what is being used to predict what.

@App:name("TensorFlowTestApp")

define stream InputStream (x string);

@sink(type='log') 
define stream OutputStream (outputPoint0 double, outputPoint1 double);

@info(name = 'query1')
from InputStream#tensorFlow:predict('{SP_HOME}/samples/artifacts/TensorflowSample/Regression', 'inputPoint', 'outputPoint', x)
select outputPoint0, outputPoint1
insert into OutputStream;

Can someone please help me understand this?


Solution

  • Pleas find the documentation here. In the sample provided a simple linear regression model is used. You give a 2 dimensional x coordinate for which you will receive a 2 dimensional y coordinated predicted from the saved model.

    What parameters you pass into predict will depend on what parameters are required for prediction and this will change from model to model. In this case x coordinate is required. You can pass values to x coordinate using the Siddhi editor event simulation by following the sample. Please note that the 2 dimensional x coordinate should be passed as a string like "[1,-2]" in the event simulation.

    "inputPoint" is the name of the node in the TensorFlow graph to which we inject values from our stream. "outputPoint" is the name of the prediction output node from which we read the prediction values. Since Siddhi doesn't know the node names in TensorFlow models (user can use whatever the TensorFlow model he has trained) we need to pass the input and output names as parameters in to predict. The first parameter is the path to your TensorFlow model.