Exemple #1
0
    def set_generator(self, generator_circuit: Optional[Union[QuantumCircuit,
                                                              UnivariateVariationalDistribution,
                                                              MultivariateVariationalDistribution]
                                                        ] = None,
                      generator_init_params: Optional[np.ndarray] = None,
                      generator_optimizer: Optional[Optimizer] = None,
                      generator_gradient: Optional[Union[Callable, Gradient]] = None):
        """Initialize generator.

        Args:
            generator_circuit: parameterized quantum circuit which sets
                the structure of the quantum generator
            generator_init_params: initial parameters for the generator circuit
            generator_optimizer: optimizer to be used for the training of the generator
            generator_gradient: A Gradient object, or a function returning partial
                derivatives of the loss function w.r.t. the generator variational
                params.
        Raises:
            AquaError: invalid input
        """
        if generator_gradient:
            if not isinstance(generator_gradient, (Gradient, FunctionType)):
                raise AquaError('Please pass either a Gradient object or a function as '
                                'the generator_gradient argument.')
        self._generator = QuantumGenerator(self._bounds, self._num_qubits,
                                           generator_circuit, generator_init_params,
                                           generator_optimizer,
                                           generator_gradient,
                                           self._snapshot_dir)
Exemple #2
0
 def set_generator(self, generator_circuit=None,
                   generator_init_params=None, generator_optimizer=None):
     """
     Initialize generator.
     Args:
         generator_circuit (VariationalForm): parameterized quantum circuit which sets
                             the structure of the quantum generator
         generator_init_params(numpy.ndarray): initial parameters for the generator circuit
         generator_optimizer (Optimizer): optimizer to be used for the training of the generator
     """
     self._generator = QuantumGenerator(self._bounds, self._num_qubits,
                                        generator_circuit, generator_init_params,
                                        self._snapshot_dir)
Exemple #3
0
    def set_generator(self, generator_circuit=None, generator_init_params=None, generator_optimizer=None):
        """
        Initialize generator.
        Args:
            generator_circuit: VariationalForm, parametrized quantum circuit which sets the structure of the quantum
                               generator
            generator_init_params: array, initial parameters for the generator circuit
            generator_optimizer: Optimizer, optimizer to be used for the training of the generator

        Returns:

        """
        self._generator = QuantumGenerator(self._bounds, self._num_qubits, generator_circuit, generator_init_params,
                                           self._snapshot_dir)
        return
Exemple #4
0
    def set_generator(self, generator_circuit: Optional[Union[QuantumCircuit,
                                                              UnivariateVariationalDistribution,
                                                              MultivariateVariationalDistribution]
                                                        ] = None,
                      generator_init_params: Optional[np.ndarray] = None,
                      generator_optimizer: Optional[Optimizer] = None):
        """Initialize generator.

        Args:
            generator_circuit: parameterized quantum circuit which sets
                the structure of the quantum generator
            generator_init_params: initial parameters for the generator circuit
            generator_optimizer: optimizer to be used for the training of the generator
        """
        self._generator = QuantumGenerator(self._bounds, self._num_qubits,
                                           generator_circuit, generator_init_params,
                                           self._snapshot_dir)