How to see the output(s) (hidden state + cell state) as well as the weights (input + recurrent) of LSTM network after training?

2 views (last 30 days)
Yildirim Kocoglu
Yildirim Kocoglu on 30 Nov 2020
I'm trying to make sense of the LSTM workflow (how the internal calculations are done). I know that it is clearly pointed out in the matlab documentation with the formulas which is great but, I would like to see the outputs to better understand those formulas. I also understand that there is a backpropogation through time to find the weights but, for the time being, I'm not concerned about that yet.
My main concern is seeing the outputs (hidden state + cell state) at each time step of sequence(s) and weights after the training is over to better understand the flow of information in an LSTM block and from LSTM block-to-LSTM block.
I'm also trying to understand if the dimension of the weights that are learned change with the number of examples given (for example: heart rate or motion measurements of different people that may be doing different activities such as dancing, sitting, walking, etc. with different sequence lengths for each person.).
When I type (hiddenstate at t=0):
layers(2,1).HiddenState
for an lstm layer, the answer is "[]" if nothing is specified by the user at the beginning but, can I see if it actually randomly chooses some numbers during training instead of "[]"?
Or if I actually initialize the hiddenstate myself, how does it change for each timestep (I would like to see the actual numbers if possible). I'm also trying to see the cell state outputs at each time step.
The main reason, I'm trying to achieve this is because I'm trying to concatonate static features to the hidden state (output of LSTM) before passing it to a dense layer (fully connected layer) however, my multi input DAG network is not working (Error: if there is a sequence input layer, you can't have any other layer) and I'm trying to find an alternative solution to it which will require me to understand the workflow a little more in depth. The question I posted is here: https://www.mathworks.com/matlabcentral/answers/666768-how-to-use-dag-network-multi-input-network-static-temporal-inputs-using-lstm-and-fully-connecte?s_tid=prof_contriblnk
Any suggestions and any help is appreciated.
Thank you.

Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!