Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient compute fail when using RawFeatureVector #95

Closed
saalimon opened this issue May 11, 2021 · 2 comments
Closed

Gradient compute fail when using RawFeatureVector #95

saalimon opened this issue May 11, 2021 · 2 comments
Assignees
Labels
priority: low type: enhancement ✨ Features or aspects to improve

Comments

@saalimon
Copy link

Information

  • Qiskit Machine Learning version: 0.1.0
  • Python version: 3.7.10
  • Operating system: All

What is the current behavior?

This message occurs when using RawFeatureVector with CircuitStateFn
Cannot compute gradient operator! Continuing without gradients!

Steps to reproduce the problem

from qiskit import QuantumCircuit
from qiskit.opflow import StateFn, PauliSumOp, AerPauliExpectation, Gradient
from qiskit.utils import QuantumInstance
from qiskit_machine_learning.neural_networks import OpflowQNN
from qiskit_machine_learning.circuit.library import RawFeatureVector

expval = AerPauliExpectation()
gradient = Gradient()
qi_sv = QuantumInstance(Aer.get_backend('statevector_simulator'))

inputs = RawFeatureVector(16)
qc = QuantumCircuit(4)
qc.append(inputs,range(4))
qc_sfn = StateFn(qc)
H1 = StateFn(PauliSumOp.from_list([('Z', 1.0)]))
op = ~H1 @ qc_sfn
qnn4 = OpflowQNN(operator = op, input_params = inputs.parameter, weight_params = [], exp_val = expval, gradient = gradient, quantum_instance = qi_sv)

What is the expected behavior?

Can pass the Parameter or ParameterVector to OpflowQNN or another Opflow from qiskit_machine_learning.neural_networks

Suggested solutions

Check the Gradient condition on qiskit.opflow

@ElePT
Copy link
Collaborator

ElePT commented Jun 23, 2021

Hello! I would like to work on this issue.

@adekusar-drl adekusar-drl added status: need information Further information is requested priority: low type: enhancement ✨ Features or aspects to improve and removed status: need information Further information is requested labels Jun 23, 2021
@adekusar-drl
Copy link
Collaborator

Closed in #182.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low type: enhancement ✨ Features or aspects to improve
Projects
None yet
Development

No branches or pull requests

3 participants