# LSTM-Quantum Kernel Method

**URL:** <https://discuss.pennylane.ai/t/lstm-quantum-kernel-method/4925>\
**Category:** PennyLane Help\
**Created:** [July 23, 2024, 8:09am UTC](https://discuss.pennylane.ai/t/lstm-quantum-kernel-method/4925 "2024-07-23T08:09:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![candeer12376](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/candeer12376/32/2720_2.png) [@candeer12376](https://discuss.pennylane.ai/u/candeer12376)\
**Post date:** [July 23, 2024, 8:09am UTC](https://discuss.pennylane.ai/t/lstm-quantum-kernel-method/4925/1 "2024-07-23T08:09:38Z")

</div>

I am now trying to replace the VQC circuit with a Quantum Kernel Circuit form circuit on the original QLSTM, but I am not sure whether my input Tensor can be directly split into x1 and x2, and I only want the probability of taking the base state of 0 like this Is it feasible?

```auto
 def _circuit_input(self, inputs,weights):
        if inputs.dim() == 1:
            inputs = inputs.unsqueeze(0)
        
       
        if inputs.shape[0] < 2:
            if inputs.shape[1] < 2:
                raise ValueError("Input tensor must have at least 2 elements")
            x1, x2 = torch.chunk(inputs, 2, dim=1)
        else:
            x1, x2 = torch.chunk(inputs, 2, dim=0)

        for wire in self.wires_input:
            qml.Hadamard(wires=wire)
        qml.templates.AngleEmbedding(x1, wires=self.wires_input, rotation='Z')
        qml.templates.AngleEmbedding(x1, wires=self.wires_input, rotation='Y')
        for i in range(len(self.wires_input) - 1):
            qml.CNOT(wires=[self.wires_input[i], self.wires_input[i + 1]])
        
        qml.templates.AngleEmbedding(x1, wires=self.wires_input, rotation='Z')
       
       #Inverse
        qml.templates.AngleEmbedding(x2, wires=self.wires_input, rotation='Z')
        for i in range(len(self.wires_input) - 1, 0, -1):
             qml.CNOT(wires=[self.wires_input[i-1], self.wires_input[i]])
        qml.templates.AngleEmbedding(x2, wires=self.wires_input, rotation='Y')  
        qml.templates.AngleEmbedding(x2, wires=self.wires_input, rotation='Z')
        for wire in self.wires_input:
            qml.Hadamard(wires=wire)
        proj_0 = qml.Projector([0] * len(self.wires_input), wires=self.wires_input)
        return qml.expval(proj_0) 
      

```

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [July 24, 2024, 12:18am UTC](https://discuss.pennylane.ai/t/lstm-quantum-kernel-method/4925/2 "2024-07-24T00:18:13Z")

</div>

Hi @candeer12376 ,

Welcome to the forum!

It’s hard to tell what you’re doing here and whether or not it’s correct. Are you seeing a specific error? If so please provide the full error traceback as well as a minimal (but self-contained) code example so that I can investigate.
