JaiPizGon / TSLSTMplus

GNU General Public License v3.0
0 stars 1 forks source link

Obtaining weights and biases of tslstm models #3

Open MickoAmoroto opened 6 months ago

MickoAmoroto commented 6 months ago

I am writing to inquire about the process of extracting the weight and bias estimates from an LSTMModel object created using your package. Specifically, I have trained an LSTM model and would now like to analyze its internal parameters, such as the weights and biases of the layers, to better understand the model's behavior and performance.

Despite reviewing the documentation and relevant vignettes, I have not been able to find detailed instructions on how to access these estimates. Could you kindly provide guidance or an example on how to retrieve the weight and bias estimates from an LSTMModel object? Any additional insights or references to further reading materials would also be greatly appreciated.

JaiPizGon commented 6 months ago

Thanks for reaching out!

The tensorflow LSTM model is stored in the lstm attribute of the TSLSTM object, and you can obtain its weights using the get_weights() function from tensorflow:

tslstm <- ts.lstm(
    # your model implementation here...
)
tslstm$lstm # Here is the tensorflow LSTM model
get_weights(tslstm$lstm) # Here are the weights

Please refer to the original tensorflow documentation on how the model weights are stored/retrieved using that function.

MickoAmoroto commented 6 months ago

Thanks, i just got my weight estimate based on your example. Additional question though, do these estimates stay the same throughout epochs or do this function only records the weights of the last epoch trained?

On Mon, 27 May 2024 at 23:00, Jaime Pizarroso Gonzalo < @.***> wrote:

Thanks for reaching out!

The tensorflow LSTM model is stored in the lstm attribute of the TSLSTM object, and you can obtain its weights using the get_weights() https://tensorflow.rstudio.com/reference/keras/get_weights function from tensorflow:

tslstm <- ts.lstm(

your model implementation here...

)tslstm$lstm # Here is the tensorflow LSTM model get_weights(tslstm$lstm) # Here are the weights

Please refer to the original tensorflow documentation on how the model weights are stored/retrieved using that function.

— Reply to this email directly, view it on GitHub https://github.com/JaiPizGon/TSLSTMplus/issues/3#issuecomment-2133654619, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6UFGG2GXCF7GMJQ2X5XMRTZENDCDAVCNFSM6AAAAABIK3NU56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZTGY2TINRRHE . You are receiving this because you authored the thread.Message ID: @.***>