Skip to main content
IBM Quantum Platform
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

GenerativeNetwork

class GenerativeNetwork

GitHub

Bases: abc.ABC

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, 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 GenerativeNetwork.loss()

Loss function used for optimization

set_discriminator

abstract GenerativeNetwork.set_discriminator(discriminator)

Set discriminator network.

Parameters

discriminator (Discriminator) – Discriminator used to compute the loss function.

Raises

NotImplementedError – not implemented

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


Attributes

parameter_values

Get parameter values from the generator

Raises

NotImplementedError – not implemented

Was this page helpful?
Report a bug or request content on GitHub.