modelBaseGenericNeuralNet

Extends from BaseNeuralNet.

Information

This is the most generic base class to include neural networks within Modelica. It can be used for any neural network. For easier handling the specialized versions BaseFeedForwardNeuralNet, BaseRecurrentNeuralNet and BaseStatefulRecurrentNeuralNet are available.

The most likely use case of this model is with a multi-layer perceptron neural network.

In order to include a neural network in Model, extend this base class in your own model. After extending you have to

  • give the path of the TFLite/ONNX model
  • specify the number of dimensions for in and output
  • specify the vector sizes in each input and output dimension
  • create input and output connectors
  • connect input and output connectors to the single input and single output vector of the runInference submodel

The runInference model uses flattened vectors for input and output. The total number of elements equals the product of all input or output sizes, respectively. The user has to connect the defined input and output to the flattened vectors in the same order as they are used within the created neural network.

Parameters

TypeNameDefaultDescription
IntegernInputElements (from BaseNeuralNet)product(inputSizes)
IntegernOutputElements (from BaseNeuralNet)product(outputSizes)
Selected Model
StringpathToAIModel (from BaseNeuralNet)""Choose path to AI model
Tensor sizing
IntegerinputDimensions (from BaseNeuralNet)1Number of input dimension
IntegerinputSizes (from BaseNeuralNet){1}Vector with size of tensor in each dimension
IntegeroutputDimensions (from BaseNeuralNet)1Number of output dimension
IntegeroutputSizes (from BaseNeuralNet){1}Vector with size of tensor in each dimension
RNN Timing Settings
Booleanstateful (from BaseNeuralNet)falseActivate state handling for RNN with state in-/outputs
RealsamplePeriod (from BaseNeuralNet)0Fixed sample period for RNNs
Advanced › Performance
IntegernumberOfThreads (from BaseNeuralNet)1Number of threads used for inference (0: Number of CPU cores)
Advanced › TFLite
BooleanuseFlexOps (from BaseNeuralNet)falseActivate to allow Tensorflow Flex Ops for tflite models
Advanced › ONNX
BooleanuseGPU (from BaseNeuralNet)falseActivate to use a compatible CUDA GPU for inference
IntegergpuDeviceID (from BaseNeuralNet)0CUDA device ID
SMArtInt.Internal.Types.ExecutionModeexecutionMode (from BaseNeuralNet)SMArtInt.Internal.Types.ExecutionMode.SequentialExecution mode for run inference

Components

TypeNameDefaultDescription
Internal.Utilities.Dependencies.OnnxGpuDependenciesonnxGpuDependencies (from BaseNeuralNet)
Internal.Utilities.Dependencies.TFFlexOpsDependenciestFFlexOpsDependencies (from BaseNeuralNet)
Internal.Utilities.RunInferenceFlatInputrunInference