The feature map described in the paper A rigorous and robust quantum speed-up in supervised machine learning is:
They provide a theoretical description of how this state can be created, but no actual circuit is provided.
How to create this feature map?
Hi @ankit27kh!
I don’t think we have an embedding for exactly this feature map. However you could use the Arbitrary State Preparation template to build it yourself.
Why don’t you try to create it using this template and let us know how it goes? If you manage to implement it, it would be amazing if you could contribute it to PennyLane.
Hi @ankit27kh,
Yes, implementing this feature map is not straightforward.
Unless you’re planning to implement this on hardware, the simplest way to prepare these states is likely to use the QubitStateVector operation.
I haven’t checked the details of the paper, so the following code may be implementing a different state, but hopefully it gives you an idea of how you could implement what you want:
import pennylane as qml
import numpy as np
g = 4
n_wires = 4
# creates a state vector corresponding to the desire state
# x and g should be integers
def phi(x):
dim = 2 ** n_wires
state = np.zeros(dim)
for i in range(dim):
j = (x * g ** i) % dim
state[j] += 1
norm = np.linalg.norm(state)
return state/norm
dev = qml.device('default.qubit', wires=n_wires)
@qml.qnode(dev)
def circuit(x):
qml.QubitStateVector(phi(x), wires=range(n_wires))
return qml.state()
Let me know if that helps!
Juan Miguel
Hey @jmarrazola, thanks for your input. I can not do all that I want to do without the actual circuit, but this does help out in at least getting somewhere.
1 Like