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?
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)