Import an existing TensorFlow (ONNX) algorithm
Open the ScaleOut Machine Learning Training Tool, select ‘Import an existing TensorFlow algorithm’ and click start.
Select the file path to the directory containing the digital twin model’s binaries and appsettings.json file. It does not matter if the directory contains the final version of the model’s implementation as long as the properties the algorithm trains on remain identical. The wizard will use the appsettings.json file to determine the digital twin model’s name and the digital twin model’s DLL to extract available and supported properties.
After making the selection, the wizard will show the digital twin model class that it located in the file path.
Click Next.
In the following page, select the properties that correspond to the ones used to train the TensorFlow model. The tool suggests the digital twin properties of type float (or Single) by default. In this tutorial, the Temperature, Friction, and RPM properties are available and correspond to the properties used to train our algorithm, so all 3 are selected. Click Next.
Note
In some cases, you may need to use properties that are not defined as the digital twin model’s properties. This could be because you are using a nested property (property of a property of the class), or you are computing property on the fly. For example, if you have a digital twin model that defines properties for voltage and electric current, but the machine learning algorithm is trained using power (power is computed by multiplying voltage and electric current), you could add a custom property Power and use it for anomaly detection by clicking “Add custom property”.
The Tensorflow model was trained with a data set in the form of a file with one column for each property and one column for the anomaly label. In order for the DT properties to match their respective columns, please order the digital twin properties and anomaly label to match the order in which they appeared in the training set for the TensorFlow model, by dragging and dropping properties.
For reference, our training data looked like this:
We need to order the digital twin properties to have in order: Temperature, RPM, Friction, and finally the Anomaly. Once the properties are ordered properly, click Next.
Browse to the location of your ONNX file and click Next.
Note
The training dataset and ONNX files are available on the ScaleOut DigitalTwinSamples GitHub repository.
Name the algorithm: this is the name used by the C# MessageProcessor code to look up the trained algorithm. For this tutorial, use the name “Overheating”.
Select an export location: this is the location for the zip file that contains the trained algorithm. This zip file is deployed alongside the digital twin model.
The last page shows you the modifications you need to do in your digital twin model solution to enable anomaly detection:
Add the name of the algorithm you just trained to the AppSettings.json file
Look up the “Overheating” algorithm in the C# MessageProcessor code using the context, and call the DetectAnomaly API.