modules.applications.qml.generative_modeling.training.qgan.QuantumGenerator

class QuantumGenerator(n_qubits, execute_circuit, batch_size)

Bases: object

This class defines the generator of the QGAN.

__init__(n_qubits, execute_circuit, batch_size)

Methods

__init__(n_qubits, execute_circuit, batch_size)

compute_gradient(params, discriminator, ...)

This function defines the forward pass of the generator.

execute(params, n_shots)

Forward pass of the generator.

compute_gradient(params: ndarray, discriminator: Module, criterion: callable, label: Tensor, device: str) ndarray

This function defines the forward pass of the generator.

Parameters:
  • params -- Parameters of the quantum circuit

  • discriminator -- Discriminator of the QGAN

  • criterion -- Loss function

  • label -- Label indicating of sample is true or fake

  • device -- Torch device (e.g., CPU or CUDA)

Returns:

Samples and the probability distribution generated by the quantum circuit

execute(params: ndarray, n_shots: int) tuple[Tensor, ndarray]

Forward pass of the generator.

Parameters:
  • params -- Parameters of the quantum circuit

  • n_shots -- Number of shots

Returns:

samples and the probability distribution generated by the quantum circuit