tf_agents.distributions.utils.make_from_parameters

Creates an instance of type value.type_ with the parameters in value.

For more details, see the docstrings for get_parameters and Params.

This function may raise strange errors if value is a Params created from a badly constructed object (one which does not set self._parameters properly). For example:

class MyBadlyConstructedDistribution(tfp.distributions.Categorical):
  def __init__(self, extra_arg, **kwargs):
    super().__init__(**kwargs)
    self._extra_arg = extra_arg

  ...

To fix this, make sure self._parameters are properly set:

class MyProperlyConstructedDistribution(tfp.distributions.Categorical):
  def __init__(self, extra_arg, **kwargs):
    super().__init__(**kwargs)
    # Ensure all arguments to `__init__` are in `self._parameters`.
    self._parameters = dict(extra_arg=extra_arg, **kwargs)
    self._extra_arg = extra_arg

  ...

value A Params object; the output of get_parameters (or a modified version thereof).

An instance of value.type_.

Exception If value is a Params object and the initializer of value.type_ does not recognize accept the args structure given in value.params. This can happen if, e.g., value.type_.__init__ does not properly set self._parameters or self.parameters to match the arguments it expects.