quara.loss_function.weighted_relative_entropy module
- class WeightedRelativeEntropy(num_var=None, func_prob_dists=None, func_gradient_prob_dists=None, func_hessian_prob_dists=None, prob_dists_q=None, weights=None)[source]
Bases:
quara.loss_function.probability_based_loss_function.ProbabilityBasedLossFunctionConstructor
- 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.weights (Union[List[float], List[np.float64]], optional) – weights, by default None
- gradient(var, validate=False)[source]
returns the gradient of Weighted Relative Entropy.
see
gradient()- Parameters
var (numpy.ndarray) –
validate (bool) –
- Return type
numpy.ndarray
- hessian(var, validate=False)[source]
returns the Hessian of Weighted Relative Entropy.
see
hessian()- Parameters
var (numpy.ndarray) –
validate (bool) –
- Return type
numpy.ndarray
- set_weights(weights)[source]
sets weights.
- Parameters
weights (List[float]) – weights.
- Return type
None
- value(var, validate=False)[source]
returns the value of Weighted Relative Entropy.
see
value()- Parameters
var (numpy.ndarray) –
validate (bool) –
- Return type
numpy.float64
- property weights: List[float]
returns weights.
- Returns
weights.
- Return type
List[float]
- class WeightedRelativeEntropyOption(mode_weight=None, weights=None, weight_name=None)[source]
Bases:
quara.loss_function.probability_based_loss_function.ProbabilityBasedLossFunctionOptionConstructor
mode_weight should be the following value:
“identity” then uses identity matrices for weights.
“custom” then uses user custom matrices for weights.
- 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