So I had a project with control system. I wanna get a math model i.e state space model or transfer function.
So after read a few research, I found out that we need to know the weight.
Before I do something like this. Get the sensor data as database. Do training in Matlab with LSTM feature and predicted. But I can’t define weight and get the final weight that its uses in training model.
What you are trying to achieve is known as system identification. You need to get training data, then train the model architecture you built to emulate that system.
Get training data:
In MATLAB/Simulink, use the transfer function block and fed it from constant block. To save the data use to workspace block.
Discretize the “to workspace” block such that the training data is not too much.
Add the “to workspace” block at the output.
Run the system to get output sequence.
Go to the workspace and save the output variable to excel such that each sample is in a column.
Add extra column for the input (the value you set in the constant block).
Repeat with different values.
You can write the model with sequential API as it is not complex.
Go to the workspace, get the input and output and store them
# https://www.tensorflow.org/api_docs/python/tf/keras/layers/LSTM
# Create a little TF Sequential LSTM Model
# (e.g: 2 Layers to iterate over weights)
lstm_model = tf.keras.models.Sequential([
tf.keras.layers.LSTM(32),
tf.keras.layers.Dense(1)
])
# Feed some random inputs through the network
input = tf.random.normal([32, 10, 8])
output = lstm_model(input)
# Get each layers weight's
for idx in range(len(lstm_model.layers)):
print('Layer ', idx)
for weights in lstm_model.layers[idx].get_weights():
print(weights.shape)
#print(weights)