How to do long short term memory with pennylane

Hello, I am very new to pennylane and could not find any demo or anything for lstm with pennylane, and am trying to understand how to do qlstm.

i want to mimic something like this very closely but just do not understand it enough. if anyone could point me to a yt video or blog or something that can help me understand how to use pennylane for qlstm, that would be much appreciated!!

Hey @Aadi_Tiwari! Welcom to the forum :tada:!

Really cool project! What I recommend doing is to start simpler. Based on your notebook, it looks like you’re trying to implement this paper. The recurrent unit is relatively complicated!

What I suggest for a “simpler” QRNN is as follows. You can keep the same circuit design as in the paper referenced above, but the bulk of your RNN recurrent unit can literally just be that circuit, where the measurements are, say, Pauli Z expectations in your embedded space. Then, you can have a classical processing layer (a softmax layer) to turn the measurement data from your quantum RNN into a probability vector (the final output of your recurrent cell).

On paper this should work! Try this out and see if you can get that functioning (it may not be very “trainable”, per se, but this simpler algorithm should still have the same properties of any other RNN).

thank you so much for replying! to be honest though i understood very little of what you said since i am very new to pennylane, and was wondering if you could give me a resource to help me learn regression with pennylane

Hey! Sorry about that! The notebook that you attached, is that your work? I assumed that it was :sweat_smile:! Are you just wanting to better understand how RNNs work, then translate that knowledge to better understanding the paper & notebook that you attached?

Haha I should’ve made clear that the link wasn’t mine, my bad. Yeah, I would like to understand RNNs to understand what he did so I can edit that code to work for my situation, otherwise I would have no idea what I would be doing

important to note that i want to understand RNNs and LSTM to use it for non linear regression

That’s awesome! I really recommend checking out Andrew’s Coursera course to learn about anything in classical machine learning. Here is the link specifically to the lesson on RNNs:

That’s what I learned from when learning about RNNs!