quara.loss_function.probability_based_loss_function module
- class ProbabilityBasedLossFunction(num_var=None, func_prob_dists=None, func_gradient_prob_dists=None, func_hessian_prob_dists=None, prob_dists_q=None)[source]
Bases:
quara.loss_function.loss_function.LossFunctionConstructor
Subclasses have a responsibility to set
on_value,on_gradient,on_hessian.- Parameters
num_var (int, optional) – number of variables, by default None
func_prob_dists (List[Callable[[np.ndarray], np.ndarray]], optional) – functions map variables to a probability distribution.
func_gradient_prob_dists (List[Callable[[int, np.ndarray], np.ndarray]], optional) – functions map variables and an index of variables to gradient of probability distributions.
func_hessian_prob_dists (List[Callable[[int, int, np.ndarray], np.ndarray]], optional) – functions map variables and indices of variables to Hessian of probability distributions.
prob_dists_q (List[np.ndarray], optional) – vectors of
q, by default None.
- property func_gradient_prob_dists: List[Callable[[int, numpy.ndarray], numpy.ndarray]]
returns functions map variables and an index of variables to gradient of probability distributions.
- Returns
functions map variables and an index of variables to gradient of probability distributions.
- Return type
List[Callable[[int, np.ndarray], np.ndarray]]
- property func_hessian_prob_dists: List[Callable[[int, int, numpy.ndarray], numpy.ndarray]]
returns functions map variables and indices of variables to Hessian of probability distributions.
- Returns
functions map variables and indices of variables to Hessian of probability distributions.
- Return type
List[Callable[[int, int, np.ndarray], np.ndarray]]
- property func_prob_dists: List[Callable[[numpy.ndarray], numpy.ndarray]]
returns functions map variables to a probability distribution.
- Returns
functions map variables to a probability distribution.
- Return type
List[Callable[[np.ndarray], np.ndarray]]
- property on_func_gradient_prob_dists: bool
returns whether or not to support
func_gradient_dists.- Returns
whether or not to support
func_gradient_dists.- Return type
bool
- property on_func_hessian_prob_dists: bool
returns whether or not to support
func_hessian_dists.- Returns
whether or not to support
func_hessian_dists.- Return type
bool
- property on_func_prob_dists: bool
returns whether or not to support
func_prob_dists.- Returns
whether or not to support
func_prob_dists.- Return type
bool
- property on_prob_dists_q: bool
returns whether or not to support
prob_dists_q.- Returns
whether or not to support
prob_dists_q.- Return type
bool
- property prob_dists_q: List[numpy.ndarray]
returns vectors of
q, by default None.- Returns
vectors of
q, by default None.- Return type
List[np.ndarray]
- set_from_standard_qtomography_option_data(qtomography, option, data, is_gradient_required, is_hessian_required)[source]
sets settings of loss function.
- Parameters
qtomography (StandardQTomography) – StandardQTomography for settings of loss function.
option (LossFunctionOption) – ProbabilityBasedLossFunctionOption for settings of loss function.
data (List[Tuple[int, np.ndarray]]) – empirical distributions for settings of loss function.
is_gradient_required (bool) – whether or not to require gradient.
is_hessian_required (bool) – whether or not to require Hessian.
- Return type
None
- set_func_gradient_prob_dists(func_gradient_prob_dists)[source]
sets functions map variables and an index of variables to gradient of probability distributions.
- Parameters
func_gradient_prob_dists (List[Callable[[int, np.ndarray], np.ndarray]]) – functions map variables and an index of variables to gradient of probability distributions.
- Return type
None
- set_func_gradient_prob_dists_from_standard_qt(qt)[source]
sets the gradient of probability distributions from StandardQTomography.
- Parameters
qt (StandardQTomography) – StandardQTomography to set the gradient of probability distributions.
- Return type
None
- set_func_hessian_prob_dists(func_hessian_prob_dists)[source]
sets functions map variables and indices of variables to Hessian of probability distributions.
- Parameters
func_hessian_prob_dists (List[Callable[[int, int, np.ndarray], np.ndarray]]) – functions map variables and indices of variables to Hessian of probability distributions.
- Return type
None
- set_func_hessian_prob_dists_from_standard_qt(qt)[source]
sets the Hessian of probability distributions from StandardQTomography.
- Parameters
qt (StandardQTomography) – StandardQTomography to set the Hessian of probability distributions.
- Return type
None
- set_func_prob_dists(func_prob_dists)[source]
sets functions map variables to a probability distribution.
- Parameters
func_prob_dists (List[Callable[[np.ndarray], np.ndarray]]) – functions map variables to a probability distribution.
- Return type
None
- set_func_prob_dists_from_standard_qt(qt)[source]
sets the function of probability distributions from StandardQTomography.
- Parameters
qt (StandardQTomography) – StandardQTomography to set the function of probability distributions.
- Return type
None
- class ProbabilityBasedLossFunctionOption(mode_weight, weights=None, weight_name=None)[source]
Bases:
quara.loss_function.loss_function.LossFunctionOptionConstructor
- Parameters
mode_weight (str, optional) – mode weight, by default None
weights (List, optional) – list of weight, by default None
weight_name (str, optional) – weight name for reporting, by default None