-
Notifications
You must be signed in to change notification settings - Fork 318
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
Neural networks update #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me for initial commit. We can then adjust sparse logic, add batching, etc. in separate PRs.
"""Initializes the Circuit Quantum Neural Network. | ||
|
||
Args: | ||
circuit: The (parametrized) quantum circuit that generates the samples of this network. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameterized is in () as this optional, ie the circuit is a Circuit and can optionally be parameterized. If so then input_params and weight params needs to be defined, such that the total set of params there match what the circuit needs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now parameterized is not in (). Circuit should be parameterized, otherwise it does not make much sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it does make sense, you can use the circuit in a pytorch setting and train a classical NN based on the samples.
# TODO this should not be necessary... but currently prop grads fail otherwise | ||
from qiskit import Aer | ||
self._sampler = CircuitSampler(Aer.get_backend('statevector_simulator'), param_qobj=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, hopefully we don't need that. If there was any need to do something we should use BasicAer since Aer is still really an optional install and not part of Qiskit core (i.e. Terra)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependency on Aer is removed.
QiskitMachineLearningError: Invalid parameter values. | ||
""" | ||
if num_inputs < 0: | ||
raise QiskitMachineLearningError('Number of inputs cannot be negative!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its always nice to have the invalid value etc in these error messages of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added invalid values to the messages.
"""Initializes the Opflow Quantum Neural Network. | ||
|
||
Args: | ||
operator: The parametrized operator that represents the neural network. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not have parameterized in () - but given the following params default to None I guess though this is analgous to the circuit based ine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the circuits.
self.quantum_instance, | ||
param_qobj=is_aer_provider(self.quantum_instance.backend) | ||
) | ||
# TODO: replace by extended caching in circuit sampler after merged: "caching='all'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI This has been merged already Qiskit/qiskit#5934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now make use of caching="all"
.
* moving to public * mypy, spell, other fixes * more on sphinx * more on sphinx * more on sphinx * fix docs * type hints * fix mypy Co-authored-by: Manoel Marques <Manoel.Marques@ibm.com> Co-authored-by: Stefan Woerner <WOR@zurich.ibm.com>
Summary
New implementations of QNNs.
Details and comments
This includes:
Authored by @stefan-woerner, edited by @adekusar-drl.