concepts.language.neural_ccg.ckyee.CKYEEExpectationFunction#
- class CKYEEExpectationFunction[source]#
Bases:
object
A collection of functions to perform expected execution. This class maintains a set of functions of the following form:
def expectation_<typename>(self, values: List[Value], weights: List[torch.Tensor]) -> Tuple[Optional[Value], Optional[Tuple[torch.Tensor, float]]]: ...
where
typename
is the name of a type, andvalues
is a list of values of the type, andweights
is a list of corresponding weights. The function should return a tuple of (expectation, (sum_weight, max_weight)), whereexpectation
is the expectation of the values, as aValue
instance, andsum_weight
is the sum of the weights (as a PyTorch tensor), andmax_weight
is the maximum of the weights (as a float).Methods
expectation
(values, weights)Compute the expectation of a list of values.
get_function
(typename)Get the registered function for a type.
register_function
(typename, function)Register a function to compute the expectation of a list of values.
- __init__(domain)[source]#
Initialize the expectation function.
- Parameters:
domain (FunctionDomain) – the function domain.
- __new__(**kwargs)#
- expectation(values, weights)[source]#
Compute the expectation of a list of values.
- Parameters:
- Returns:
A tuple of (expectation, (sum_weight, max_weight)). The
expectation
is the expectation of the values, as aValue
instance. The second element is a tuple of (sum_weight, max_weight), wheresum_weight
is the sum of the weights (as a PyTorch tensor), andmax_weight
is the maximum of the weights (as a float).- Return type: