tf.contrib.eager.make_template
Stay organized with collections
Save and categorize content based on your preferences.
Make a template, optionally compiling func_ into a graph function.
tf.contrib.eager.make_template(
name_, func_, create_scope_now_=False, unique_name_=None, custom_getter_=None,
create_graph_function_=False, **kwargs
)
See make_template
for full documentation.
Args |
name_
|
A name for the scope created by this template. If necessary, the name
will be made unique by appending _N to the name.
|
func_
|
The function to wrap.
|
create_scope_now_
|
Boolean controlling whether the scope should be created
when the template is constructed or when the template is called. Default
is False, meaning the scope is created when the template is called.
|
unique_name_
|
When used, it overrides name_ and is not made unique. If a
template of the same scope/unique_name already exists and reuse is false,
an error is raised. Defaults to None. If executing eagerly, must be None.
|
custom_getter_
|
Optional custom getter for variables used in func_ . See
the tf.compat.v1.get_variable custom_getter documentation for more
information.
|
create_graph_function_
|
When True, func_ will be executed as a graph
function. This implies that func_ must satisfy the properties that
function.defun requires of functions: See the documentation of
function.defun for details. When executing eagerly, setting this flag
to True can improve performance. Regardless of whether eager execution
is enabled, enabling this flag gives the caller access to graph-function
semantics, i.e., accesses to variables are totally ordered and
side-effecting ops are not pruned.
|
**kwargs
|
Keyword arguments to apply to func_ .
|
Returns |
A function to encapsulate a set of variables which should be created once
and reused. An enclosing scope will be created either when make_template
is called or when the result is called, depending on the value of
create_scope_now_ . Regardless of the value, the first time the template
is called it will enter the scope with no reuse, and call func_ to create
variables, which are guaranteed to be unique. All subsequent calls will
re-enter the scope and reuse those variables.
|
Raises |
ValueError
|
if name_ is None.
|
ValueError
|
if unique_name_ is not None and eager execution is enabled.
|
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 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.eager.make_template\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/ops/template.py#L164-L231) |\n\nMake a template, optionally compiling func_ into a graph function. \n\n tf.contrib.eager.make_template(\n name_, func_, create_scope_now_=False, unique_name_=None, custom_getter_=None,\n create_graph_function_=False, **kwargs\n )\n\nSee `make_template` for full documentation.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name_` | A name for the scope created by this template. If necessary, the name will be made unique by appending `_N` to the name. |\n| `func_` | The function to wrap. |\n| `create_scope_now_` | Boolean controlling whether the scope should be created when the template is constructed or when the template is called. Default is False, meaning the scope is created when the template is called. |\n| `unique_name_` | When used, it overrides name_ and is not made unique. If a template of the same scope/unique_name already exists and reuse is false, an error is raised. Defaults to None. If executing eagerly, must be None. |\n| `custom_getter_` | Optional custom getter for variables used in `func_`. See the [`tf.compat.v1.get_variable`](../../../tf/get_variable) `custom_getter` documentation for more information. |\n| `create_graph_function_` | When True, `func_` will be executed as a graph function. This implies that `func_` must satisfy the properties that `function.defun` requires of functions: See the documentation of `function.defun` for details. When executing eagerly, setting this flag to True can improve performance. Regardless of whether eager execution is enabled, enabling this flag gives the caller access to graph-function semantics, i.e., accesses to variables are totally ordered and side-effecting ops are not pruned. |\n| `**kwargs` | Keyword arguments to apply to `func_`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A function to encapsulate a set of variables which should be created once and reused. An enclosing scope will be created either when `make_template` is called or when the result is called, depending on the value of `create_scope_now_`. Regardless of the value, the first time the template is called it will enter the scope with no reuse, and call `func_` to create variables, which are guaranteed to be unique. All subsequent calls will re-enter the scope and reuse those variables. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|---------------------------------------------------------------|\n| `ValueError` | if `name_` is None. |\n| `ValueError` | if `unique_name_` is not None and eager execution is enabled. |\n\n\u003cbr /\u003e"]]