qiskit.aqua.components.neural_networks.GenerativeNetwork
class GenerativeNetwork
Base class for generative Quantum and Classical Neural Networks.
This method should initialize the module, but raise an exception if a required component of the module is not available.
__init__
abstract __init__()
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__ () | Initialize self. |
get_output (quantum_instance, params, shots) | Apply quantum/classical neural network to given input and get the respective output |
loss () | Loss function used for optimization |
set_discriminator (discriminator) | Set discriminator network. |
set_seed (seed) | Set seed. |
train ([quantum_instance, shots]) | Perform one training step w.r.t to the generator’s parameters |
Attributes
parameter_values | Get parameter values from the generator |
get_output
abstract get_output(quantum_instance, params, shots)
Apply quantum/classical neural network to given input and get the respective output
Parameters
- quantum_instance (QuantumInstance) – Quantum Instance, used to run the generator circuit.
- params (numpy.ndarray) – parameters which should be used to run the generator, if None use self._params
- shots (int) – if not None use a number of shots that is different from the number set in quantum_instance
Returns
Neural network output
Raises
NotImplementedError – not implemented
loss
abstract loss()
Loss function used for optimization
parameter_values
abstract property parameter_values
Get parameter values from the generator
Raises
NotImplementedError – not implemented
set_discriminator
abstract set_discriminator(discriminator)
Set discriminator network.
Parameters
discriminator (Discriminator) – Discriminator used to compute the loss function.
Raises
NotImplementedError – not implemented
set_seed
abstract set_seed(seed)
Set seed.
Parameters
seed (int) – seed
Raises
NotImplementedError – not implemented
train
abstract train(quantum_instance=None, shots=None)
Perform one training step w.r.t to the generator’s parameters
Parameters
- quantum_instance (QuantumInstance) – used to run generator network. Ignored for a classical network.
- shots (int) – Number of shots for hardware or qasm execution. Ignored for classical network
Returns
generator loss and updated parameters.
Return type
dict
Raises
NotImplementedError – not implemented