modelEvaluateRecurrentNeuralNet

Diagram of EvaluateRecurrentNeuralNet

Extends from BaseClasses.BaseRecurrentNeuralNet.

Information

Use this block if you want to include a recurrent neural network in Modelica.

Please place this block in your model and

  • give the path to the TFLite/ONNX model
  • specify the number of inputs
  • specify the sampling interval and how many elements from previous times should be fed into the net
  • provide the values for the input of the block and use the outputs in the same manner as it was done during training

In continuous mode the historic values are generated by a delay. You could choose between the computational improved Clara-Delay and the delay in the Modelica-Standard-Library. If continuous is deactivated the model will create an event when reaching the sampling time - this should be avoided for performance reasons.

As tensorflow lite uses a flattened input array, you have to specify the flattening method. In the standard tensorflow setting you have to use the predefined option OldFirstInputSequential.

The example TF_PI_RNN_tflite uses this block.

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
IntegernHistoricElements (from BaseRecurrentNeuralNet)10Number of elements from sampling steps for each input fed to the neural net
Booleancontinuous (from BaseRecurrentNeuralNet)false=true: model operates continuously; input values are delayed
BooleanuseClaRaDelay (from BaseRecurrentNeuralNet)trueUse the ClaRa delay instead of MSL delay
Advanced › Performance
IntegernumberOfThreads (from BaseNeuralNet)1Number of threads used for inference (0: Number of CPU cores)
Input/Output Sizing
IntegernumberOfInputs (from BaseRecurrentNeuralNet)1Number of input values
IntegernumberOfOutputs (from BaseRecurrentNeuralNet)1Number of output values
IntegerbatchSize (from BaseRecurrentNeuralNet)1Number of parallel batched simulations
BooleanreturnSequences (from BaseRecurrentNeuralNet)false

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealInput[numberOfInputs]u
Modelica.Blocks.Interfaces.RealOutput[numberOfOutputs]y

Components

TypeNameDefaultDescription
Internal.Utilities.RunInterferenceRNNrunInterferenceHistory (from BaseRecurrentNeuralNet)