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.
Methods
get_output
abstract GenerativeNetwork.get_output(quantum_instance, qc_state_in, 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.
- qc_state_in (QuantumCircuit or vector) – corresponding to the network input state
- 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 GenerativeNetwork.loss()
Loss function used for optimization
set_seed
abstract GenerativeNetwork.set_seed(seed)
Set seed.
Parameters
seed (int) – seed
Raises
NotImplementedError – not implemented
train
abstract GenerativeNetwork.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