from_params and param_shapes for easy distribution construction
This CL enables users to programmatically switch between different distribution types (e.g. by command line flag) and have minimal custom logic for each distribution type, specifically knowing the names of the distribution parameters and their required constraints (e.g. positivity for a Normal's sigma). This is done through 2 static functions: param_shapes, which returns the name and shape of parameters for a given desired sample shape, and from_params, which takes parameter kwargs, by default constrains them (e.g. apply softplus to the sigma parameter to make it positive), and returns an instance of the distribution with the (constrained) parameters. Change: 130437416
Loading
Please sign in to comment