Questions tagged [pennylane]

PennyLane is a cross-platform Python library for quantum machine learning, automatic differentiation, and optimization of hybrid quantum-classical computations.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

Custom gate labels in PennyLane

I have a circuit with Rx gate, and I want to draw it with changed gate label. For example, instead of "RX" I want to have "custom_gate" written in the gate box. I have tried ...
Daniil Tarpanov's user avatar
1 vote
1 answer
28 views

How to save a hybrid Tensorflow and Pennylane model?

I implemented a hybrid model with Keras and Pennylane that looks like this: The quantum layer is basically a quantum circuit converted to a keras layer with the ...
Ryan Wang's user avatar
  • 185
1 vote
1 answer
42 views

Error loading saved hybrid quantum (pennylane + tensorflow keras) model: Unknown layer: 'KerasLayer'

I'm creating a hybrid model consisting of classical convolutional layers and a quantum output using Tensorflow. I can save the model in either .h5 or .keras format, but when I load them with the code <...
Ryan Wang's user avatar
  • 185
1 vote
0 answers
35 views

Classical Fisher Information for 1-qubit vs 2-qubit in PennyLane

I'm attempting to examine the Classical Fisher Information (CFI) for a 1-qubit system in comparison to a 2-qubit system.(PennyLane) I anticipated that the CFI for the 2-qubit system would be double(at ...
Donguk kim's user avatar
1 vote
0 answers
35 views

How can I pass multiple embeddings in my function?

I have a problem with my code. I would like to try multiple embeddings in my kernel (I'm using the adjoint method). My idea is to pass them to the function and use them depending on what I pass. ...
BootBootBoot's user avatar
2 votes
0 answers
60 views

Plotting Fisher Information using PennyLane

I made 2-qubit based circuit with post-selection method. Post-selection method is, Let $$ K = \begin{bmatrix} \sqrt{1-\gamma} & 0 \\ 0 & 1 \end{bmatrix}\,. $$ Then, $$ \rho_{\text{post-...
Donguk kim's user avatar
2 votes
0 answers
63 views

SLSQP optimizer(scipy.minimize) doesn't update parameters

I'm trying to find optimal parameters that minimize the cost functions. In cost function, it calculates the classical-fisher-information at a certain point(phi[0] = np.pi). Cost-function takes 3-...
Donguk kim's user avatar
2 votes
0 answers
43 views

Post-selection on pennylane

I want to do something like this: For a single-qubit Apply Hadamard -> Time_evolution -> Phase_damping -> Hadamard -> Post-selection -> Get CFI(classical fisher info) Density matrix ...
Donguk kim's user avatar
1 vote
1 answer
102 views

Create qnode with density matrix on pennylane

I'm using pennylane. What I want to do is Create a qnode with the 2*2 density matrix of a single qubit one. It has the parameter as phi Given density matrix: $$\...
Donguk kim's user avatar
2 votes
1 answer
112 views

Problems trying to plot the classical Fisher information with Pennylane

I'm working with pennylane. My goal is to plot CFI(Classical Fisher Information)with following quantum state. With the above equation I set gamma as 0. Then It becomes: If gamma is not equal to zero,...
Donguk kim's user avatar
1 vote
0 answers
30 views

Pennylane variational classifier demo - need for padding

In the variational classifier demo from Pennylane, the data loading is performed with ...
Sarvapriya Tripathi's user avatar
1 vote
1 answer
59 views

Implementing swap test on quantum register

I'm interested in implementing a controlled-swap operation on quantum registers. However, it appears that Qiskit's documentation primarily focuses on single qubits rather than registers. Could you ...
Yuval Idan's user avatar
1 vote
1 answer
59 views

Where is the input data X in the CV-QNN as presented in Pennylane?

I am referring to the tutorial of CV-QNN in Pennylane(Strawberry Fields). Each layer of CV-QNN can perform the operation below. Unlike other quantum neural network tutorials, where the input X and y ...
user48217's user avatar
1 vote
0 answers
104 views

Drawing circuit in pennylane

I am trying to draw the circuit in pennylane but even after my hours of trying I am completely unsuccessful. Below is my code. Any little guidance of yours can help me a lot. ...
Manu's user avatar
  • 43
1 vote
0 answers
50 views

Why VQE don't work?

I try to make VQE optimizer, but something goes wrong at the optimization stage, more precisely, the parameters do not change and there is no gradient descent. Please tell me what I'm doing wrong? <...
Сударь Сударев's user avatar
2 votes
1 answer
171 views

How can Mid-Circuit Measurements be performed in pennylane

I am trying to understand how to do mid circuit measurements in pennylane. As an example here is a simple preperation of a bell state: ...
Constantin Economides's user avatar
0 votes
0 answers
53 views

Data encoding (PennyLane) vs feature map (Qiskit)

I am new to quantum machine learning and I came across data encoding (in Pennylane) and feature map (in Qiskit). What are their similarities and differences?
sllama's user avatar
  • 1
2 votes
0 answers
105 views

Comparative analysis of TensorFlow-Quantum, Pennylane, and Qiskit, to implement quantum CNNs

I am currently working on a project wherein I have to implement a Quantum Convolutional Neural Network. The best options for NISQ devices are hybrid algorithms, so I will try integrating quantum ...
Chan's user avatar
  • 121
0 votes
0 answers
20 views

Ensemble classification with Rigetti and Qiskit devices : Params.npy

I want ask how the params.npy variable were obtained? It would be great if you provide the codes for my better understanding. ...
Mas Dim's user avatar
1 vote
1 answer
59 views

Qubits are drawn multiple times in circuit using pennylane

When I draw my circuits some qubits are drawn multiple times (see 'circuit 1'). Does this mean that 1) the circuit itself is the same as 'circuit 2' below or 2) do I have some bug in my code that ...
qcabepsilon's user avatar
1 vote
1 answer
144 views

Implementing time evolution gate for density matrix in PennyLane circuit

I am trying to create a circuit which time evolves a density matrix $\hat{\rho}$ with the parameterized Hamiltonian $$\hat{H}(\theta) = e^{(-i \sum_m \theta_m \Lambda_m)}\hat{H}_ce^{(i \sum_m \theta_m ...
Silly Goose's user avatar
1 vote
0 answers
72 views

What is an initial state of a qubit in PennyLane?

I just started trying to use the PennyLane Python package. It seems like the default.qubit device initializes each wire as an up-spin qubit. However, I am not ...
Silly Goose's user avatar
1 vote
1 answer
69 views

Getting High cost function in code implementation of VQLS pennylane tutorial

I am currently trying to implement the tutorial in pennylane https://pennylane.ai/qml/demos/tutorial_vqls.html for very complex example in 3 Qubit and cost function is very high in spite of adding ...
Nithin Reddy Govindugari's user avatar
1 vote
1 answer
172 views

How does Pennylane compute expected values of single-qubit operators over real hardware?

Imagine I have a quantum circuit of n qubits and I want to measure the expected value of a single-qubit operator (let's say PauliZ) for each qubit. This is easily done in Pennylane with the following ...
Paul's user avatar
  • 70
1 vote
1 answer
126 views

How to visualize the resulting state vector using CVNeuralNetLayers and Lightning qubit device

I'm trying to learn how to use PennyLane's CVNeuralNetLayers. I wrote this code below but I am not able to use the resulting state of the circuit generated by this layer. I looked for examples in the ...
Luccas Marim's user avatar
0 votes
0 answers
32 views

PennyLane: How to shift operations in pennylane like in cirq

Cirq allows us to not shift operations all the way to the left by writing the following programs ...
Pratyush's user avatar
1 vote
1 answer
210 views

pennylane:fidelity calculation after swap test between entagled states. Swap test issue

What I am trying to do is first take an image and encode it into quantum states, for this I have taken an image from the MNIST dataset and then reshaped it to (4,4) and now I wrote the following ...
Pratyush's user avatar
2 votes
2 answers
137 views

pennylane: How to carry out MB rotation without CB rotation?

I'm looking at this MBQC tutorial where there's an example that shows that a MB and CB single qubit rotations give the same result. CB version : ...
unknown's user avatar
  • 1,942
0 votes
2 answers
302 views

How to transform an Hamiltonian operator to a controlled gate (Hadamard test) in Pennylane?

I would like to perform an Hadamard test on a given Hamiltonian operator $\hat{H}$ acting on a 2-qubits system. For instance, suppose $\hat{H}$ can be decomposed into a ...
Constantin Economides's user avatar
1 vote
1 answer
76 views

How can one append a pre-defined quantum function (circuit) to another quantum function in Pennylane?

I want to use a pennylane quantum function that i created earlier somewhere else, again in a new function but have it applied to certain wires. The reason for this is, that I have a quantum circuit of ...
Constantin Economides's user avatar
1 vote
0 answers
68 views

Convert an integer to its basis state in Cirq

I am trying to implement Quantum Adder using QFT in Cirq. I previously did the same problem using Pennylane, in which I converted an integer into its Basis state using the BasisStatePreparation method ...
Jessica John Britto's user avatar
1 vote
0 answers
63 views

The loss function decreases, but the test accuracy is always 0.5

...
Ren-Xin Zhao's user avatar
1 vote
0 answers
29 views

How do we know what angle formula X1 is encoded into qml.MottonenStatePreparation?

Known that X1 is a quantum state, it is prepared by qml.MottonenStatePreparation. How do we know what angle formula X1 is encoded into qml.MottonenStatePreparation? can be interpreted in python code. ...
Ren-Xin Zhao's user avatar
1 vote
0 answers
53 views

Universality : Working with one qubit

I am working on the Pennylane's code camp problems and I'm stuck with the challenge 4. I am utterly clueless about this question, as in what is it asking from me, they provide us with a $2\times 2$ ...
Marco Puerto's user avatar
2 votes
1 answer
428 views

Pennylane: take qml.state of one function and use it as the initialization for another

In Pennylane, I created a function to set the initial parameters of my qubit, and then called qml.state() to return the output. I now want to feed this initialization into another circuit, but I'm not ...
TuktukTaxi's user avatar
2 votes
1 answer
134 views

Computing gradients in parallel with cost from probs (Pennylane-Braket)

Do circuits that measure probabilities instead of expectation values benefit from parallel execution? The Computing gradients in parallel with Amazon Braket tutorial shows how the multiple device ...
ryanhill1's user avatar
  • 2,433
0 votes
0 answers
134 views

Pennylane: Pennylane can not train the parameters of the problem

I asked this question in the Pennylane forum, but there was no reply for a long time, the link is: https://discuss.pennylane.ai/t/why-does-the-embedding-metric-learning-case-not-work/2211?u=rx1 The ...
Ren-Xin Zhao's user avatar
0 votes
1 answer
363 views

Difference between qiskit SPSA optimize and minimize in runtime program

I use this tutorial with pennylane-qiskit.vqe_runtime_runner to familiarize myself with qiskit runtime using pennylane. Thereby, I wonder: What is the difference between qiskit.algorithms.optimizers....
qcabepsilon's user avatar
2 votes
1 answer
391 views

How can I see the circuit that was actually executed on the device in pennylane?

I do a VQE using the pennylane UCCSD ansatz for execution on the 'default.qubit' device and am interested in the actual circuit that is executed on the device (ideally without making changes in any ...
qcabepsilon's user avatar
0 votes
2 answers
426 views

Can I create a quantum circuit from a list of operations in pennylane?

Say, I have a list of operations which are pennylane gates, can I create a circuit from it? I tried: ...
qcabepsilon's user avatar
1 vote
1 answer
635 views

How to create a quantum circuit with 800+ features using PennyLane

I am new to Quantum ML, and I am currently using PennyLane to do the QML activity. As per this article, total number of features is equal to the total number of qubits. (In the example, they have ...
Shikhar's user avatar
  • 11
2 votes
0 answers
111 views

Simulating density matrices in quantum simulators

I would like to load random quantum states sampled from a given density matrix based on its classical probabilities ie based on the definition of the given density matrix: $\rho = \sum_i p_i |\psi _i \...
Ananth_Rao's user avatar
1 vote
1 answer
251 views

qml.probs with another computational basis state

I am working with pennyLane library in Python and I have a circuit that involves several operations to 10 qubits. I want to measure the occupation probability of a target state. The function qml.probs(...
Borja Aizpurua's user avatar
1 vote
1 answer
130 views

Is this Quantum Neural Network overfitting?

In the accuracy graphs (attached the graph images below) shown in this code (Binary Classification for Fraud Detection): validation loss is greater than training loss training accuracy is greater ...
kanha's user avatar
  • 11
1 vote
2 answers
342 views

Gradient descent for a quantum-classical hybrid neural network

I am working on implementing a quantum-classical hybrid neural network in qiskit where input data is encoded on a quantum circuit (with say 3 qubits) using a ...
Ananth_Rao's user avatar
2 votes
2 answers
93 views

Why does VQE with pennylane and scikit-optimize gp_minimize give 'func must be scalar' error?

I am trying to replace the SPSA optimizer in the VQE tutorial of pennylane by the bayesian optimizer of scikit-opimize. When running the code below I get the error "func should return a scalar&...
qcabepsilon's user avatar
3 votes
1 answer
63 views

Why does the parameter circuit include both the positive and negative shift terms?

In the derivation of the parameter shift rules in the original paper, the Hermitian generator $G$ of any unitary $U(\theta)=\exp[-i\theta G]$ satisfies $$ U(\pm\frac{\pi}{4r})=\frac{1}{\sqrt{2}}(I\mp\...
blackfyre's user avatar
2 votes
1 answer
112 views

Is pennylane free?

I was going through the basics of pennylane. I am able to understand that it is used for quantum neural networks. I am not sure whether it is using paid cloud computer or simulator of xandu or ibmq? ...
Manu's user avatar
  • 391
6 votes
1 answer
397 views

How linear combination of unitaries gradient work (Qiskit, PennyLane)?

I'm trying to implement linear combination of unitaries(LCU) gradient from Qiskit Gradient Framework but on PennyLane. First, i looked through the source code in Qiskit. In Qiskit LCU gradient if we ...
Natchapol Patamawisut's user avatar
1 vote
1 answer
305 views

Implementing Noise in Pennylane (using qiskit.aer)

I want to implement noise in Pennylane using qiskit as a plug-in. I found this tutorial from Pennylane. But, when testing it the bit-flip error seems to have no effect at all. Here, I made some slight ...
qcabepsilon's user avatar