tf_agents.distributions.utils.make_from_parameters
Stay organized with collections
Save and categorize content based on your preferences.
Creates an instance of type value.type_
with the parameters in value
.
tf_agents.distributions.utils.make_from_parameters(
value: tf_agents.distributions.utils.Params
) -> Any
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
...
Args |
value
|
A Params object; the output of get_parameters (or a modified
version thereof).
|
Returns |
An instance of value.type_ .
|
Raises |
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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.distributions.utils.make_from_parameters\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/distributions/utils.py#L323-L376) |\n\nCreates an instance of type `value.type_` with the parameters in `value`. \n\n tf_agents.distributions.utils.make_from_parameters(\n value: ../../../tf_agents/distributions/utils/Params\n ) -\u003e Any\n\nFor more details, see the docstrings for `get_parameters` and `Params`.\n\nThis function may raise strange errors if `value` is a `Params` created from\na badly constructed object (one which does not set `self._parameters`\nproperly). For example: \n\n class MyBadlyConstructedDistribution(tfp.distributions.Categorical):\n def __init__(self, extra_arg, **kwargs):\n super().__init__(**kwargs)\n self._extra_arg = extra_arg\n\n ...\n\nTo fix this, make sure `self._parameters` are properly set: \n\n class MyProperlyConstructedDistribution(tfp.distributions.Categorical):\n def __init__(self, extra_arg, **kwargs):\n super().__init__(**kwargs)\n # Ensure all arguments to `__init__` are in `self._parameters`.\n self._parameters = dict(extra_arg=extra_arg, **kwargs)\n self._extra_arg = extra_arg\n\n ...\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|------------------------------------------------------------------------------------|\n| `value` | A `Params` object; the output of `get_parameters` (or a modified version thereof). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An instance of `value.type_`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n\n\u003cbr /\u003e"]]