Hello everyone!
While using qml.AmplitudeEmbedding
and qml.probs()
, I encountered a strange situation. When I execute the code below, the circuit gives me a different result depending on the dtype
of pennylane.numpy.tensor.tensor
(that’s the only difference I noticed).
import pennylane as qml
from pennylane import numpy as np
dev = qml.device("default.qubit", wires=4)
@qml.qnode(dev)
def circuit(image):
qml.AmplitudeEmbedding(features=image, wires=range(4), normalize=True)
return qml.probs(wires = range(4))
test = np.array([8, 33, 38, 21, 38, 106, 114, 53, 46, 70, 75, 54, 30, 53, 54, 36])
display(test)
display(type(test))
display(circuit(test))
display(X_train[0])
display(type(X_train[0]))
display(circuit(X_train[0]))
Running the above code:
tensor([ 8, 33, 38, 21, 38, 106, 114, 53, 46, 70, 75, 54, 30,
53, 54, 36], requires_grad=True)
pennylane.numpy.tensor.tensor
tensor([0.00116362, 0.01979964, 0.02625407, 0.00801804, 0.02625407,
0.20428719, 0.23628661, 0.0510718 , 0.03847203, 0.08908929,
0.10227087, 0.05301722, 0.01636334, 0.0510718 , 0.05301722,
0.02356321], requires_grad=True)
tensor([ 8, 33, 38, 21, 38, 106, 114, 53, 46, 70, 75, 54, 30,
53, 54, 36], dtype=uint8, requires_grad=True)
pennylane.numpy.tensor.tensor
tensor([0.02825607, 0.4807947 , 0.63752759, 0.19470199, 0.63752759,
4.9607064 , 5.73774834, 1.2401766 , 0.93421634, 2.16335541,
2.48344371, 1.28741722, 0.39735099, 1.2401766 , 1.28741722,
0.57218543], requires_grad=True)
test
variable is the dtype('int32')
.I’m using qml.version = ‘0.36.0’.
Should it be like that? Should qml.probs
only returns values from 0 to 1?
Thank you for your help