tensorcircuit.applications.dqas#

Modules for DQAS framework

DQAS framework entrypoint

参数
  • kernel_func -- function with input of data instance, circuit parameters theta and structural paramter k, return tuple of objective value and gradient with respect to theta

  • g -- data generator as dataset

  • op_pool -- list of operations as primitive operator pool

  • p -- the default layer number of the circuit ansatz

  • p_nnp -- shape of circuit parameter pool, in general p_stp*l, where l is the max number of circuit parameters for op in the operator pool

  • p_stp -- the same as p in the most times

  • batch -- batch size of one epoch

  • prethermal -- prethermal update times

  • epochs -- training epochs

  • parallel_num -- parallel thread number, 0 to disable multiprocessing model by default

  • verbose -- set verbose log to print

  • vebose_func -- function to output verbose information

  • history_func -- function return intermiediate result for final history list

  • prob_clip -- cutoff probability to avoid peak distribution

  • baseline_func -- function accepting list of objective values and return the baseline value used in the next round

  • pertubation_func -- return noise with the same shape as circuit parameter pool

  • nnp_initial_value -- initial values for circuit parameter pool

  • stp_initial_value -- initial values for probabilistic model parameters

  • network_opt -- optimizer for circuit parameters theta

  • structure_opt -- optimizer for model parameters alpha

  • prethermal_opt -- optimizer for circuit parameters in prethermal stage

  • prethermal_preset -- fixed structural parameters for prethermal training

  • stp_regularization -- regularization function for model parameters alpha

  • nnp_regularization -- regularization function for circuit parameters theta

返回

tensorcircuit.applications.dqas.DQAS_search_pmb(kernel_func: Callable[[Any, Any, Sequence[int]], Tuple[Any, Any]], prob_model: Any, *, sample_func: Optional[Callable[[Any, int], Tuple[List[Any], List[List[Any]]]]] = None, g: Optional[Iterator[Any]] = None, op_pool: Optional[Sequence[Any]] = None, p: Optional[int] = None, batch: int = 300, prethermal: int = 0, epochs: int = 100, parallel_num: int = 0, verbose: bool = False, verbose_func: Optional[Callable[[], None]] = None, history_func: Optional[Callable[[], Any]] = None, baseline_func: Optional[Callable[[Sequence[float]], float]] = None, pertubation_func: Optional[Callable[[], Any]] = None, nnp_initial_value: Optional[Any] = None, stp_regularization: Optional[Callable[[Any, Any], Any]] = None, network_opt: Optional[Any] = None, structure_opt: Optional[Any] = None, prethermal_opt: Optional[Any] = None, loss_func: Optional[Callable[[Any], Any]] = None, loss_derivative_func: Optional[Callable[[Any], Any]] = None, validate_period: int = 0, validate_batch: int = 1, validate_func: Optional[Callable[[Any, Any, Sequence[int]], Tuple[Any, Any]]] = None, vg: Optional[Iterator[Any]] = None) Tuple[Any, Any, Sequence[Any]][源代码]#

The probabilistic model based DQAS, can use extensively for DQAS case for NMF probabilistic model.

参数
  • kernel_func -- vag func, return loss and nabla lnp

  • prob_model -- keras model

  • sample_func -- sample func of logic with keras model input

  • g -- input data pipeline generator

  • op_pool -- operation pool

  • p -- depth for DQAS

  • batch --

  • prethermal --

  • epochs --

  • parallel_num -- parallel kernels

  • verbose --

  • verbose_func --

  • history_func --

  • baseline_func --

  • pertubation_func --

  • nnp_initial_value --

  • stp_regularization --

  • network_opt --

  • structure_opt --

  • prethermal_opt --

  • loss_func -- final loss function in terms of average of sub loss for each circuit

  • loss_derivative_func -- derivative function for loss_func

返回

tensorcircuit.applications.dqas.evaluate_everyone(vag_func: Any, gdata: Iterator[Any], nnp: Any, presets: Sequence[Sequence[List[int]]], batch: int = 1) Sequence[Tuple[Any, Any]][源代码]#
tensorcircuit.applications.dqas.get_op_pool() Sequence[Any][源代码]#
tensorcircuit.applications.dqas.get_preset(stp: Any) Any[源代码]#
tensorcircuit.applications.dqas.get_var(name: str) Any[源代码]#

Call in customized functions and grab variables within DQAS framework function by var name str.

参数

name (str) -- The DQAS framework function

返回

Variables within the DQAS framework

返回类型

Any

tensorcircuit.applications.dqas.get_weights(nnp: Any, stp: Optional[Any] = None, preset: Optional[Sequence[int]] = None) Any[源代码]#

This function works only when nnp has the same shape as stp, i.e. one parameter for each op.

参数
  • nnp --

  • stp --

  • preset --

返回

tensorcircuit.applications.dqas.get_weights_v2(nnp: Any, preset: Sequence[int]) Any[源代码]#
tensorcircuit.applications.dqas.history_loss() Any[源代码]#
tensorcircuit.applications.dqas.micro_sample(prob_model: Any, batch_size: int, repetitions: Optional[List[int]] = None) Tuple[List[Any], List[List[Any]]][源代码]#
tensorcircuit.applications.dqas.parallel_kernel(prob: Any, gdata: Any, nnp: Any, kernel_func: Callable[[Any, Any, Sequence[int]], Tuple[Any, Any]]) Tuple[Any, Any, Any][源代码]#

The kernel for multiprocess to run parallel in DQAS function/

参数
  • prob --

  • gdata --

  • nnp --

  • kernel_func --

返回

tensorcircuit.applications.dqas.parallel_qaoa_train(preset: Sequence[int], g: Any, vag_func: Optional[Any] = None, opt: Optional[Any] = None, epochs: int = 60, tries: int = 16, batch: int = 1, cores: int = 8, loc: float = 0.0, scale: float = 1.0, nnp_shape: Optional[Sequence[int]] = None, search_func: Optional[Callable[[...], Any]] = None, kws: Optional[Dict[Any, Any]] = None) Sequence[Any][源代码]#

parallel variational parameter training and search to avoid local minimum not limited to qaoa setup as the function name indicates, as long as you provided suitable vag_func

参数
  • preset --

  • g -- data input generator for vag_func

  • vag_func -- vag_kernel

  • opt --

  • epochs --

  • tries -- number of tries

  • batch -- for optimization problem the input is in general fixed so batch is often 1

  • cores -- number of parallel jobs

  • loc -- mean value of normal distribution for nnp

  • scale -- std deviation of normal distribution for nnp

返回

tensorcircuit.applications.dqas.preset_byprob(prob: Any) Sequence[int][源代码]#
tensorcircuit.applications.dqas.qaoa_simple_train(preset: Sequence[int], graph: Union[Sequence[Any], Iterator[Any]], vag_func: Optional[Callable[[Any, Any, Sequence[int]], Tuple[Any, Any]]] = None, epochs: int = 60, batch: int = 1, nnp_shape: Optional[Any] = None, nnp_initial_value: Optional[Any] = None, opt: Optional[Any] = None, search_func: Optional[Callable[[...], Any]] = None, kws: Optional[Dict[Any, Any]] = None) Tuple[Any, float][源代码]#
tensorcircuit.applications.dqas.repr_op(element: Any) str[源代码]#
tensorcircuit.applications.dqas.set_op_pool(l: Sequence[Any]) None[源代码]#
tensorcircuit.applications.dqas.single_generator(g: Any) Iterator[Any][源代码]#
tensorcircuit.applications.dqas.van_regularization(prob_model: Any, nnp: Optional[Any] = None, lbd_w: float = 0.01, lbd_b: float = 0.01) Any[源代码]#
tensorcircuit.applications.dqas.van_sample(prob_model: Any, batch_size: int) Tuple[List[Any], List[List[Any]]][源代码]#
tensorcircuit.applications.dqas.verbose_output(max_prob: bool = True, weight: bool = True) None[源代码]#

Doesn't support prob model DQAS search.

参数
  • max_prob --

  • weight --

返回

tensorcircuit.applications.dqas.void_generator() Iterator[Any][源代码]#