tf.contrib.layers.stack
Stay organized with collections
Save and categorize content based on your preferences.
Builds a stack of layers by applying layer repeatedly using stack_args.
tf.contrib.layers.stack(
inputs, layer, stack_args, **kwargs
)
stack
allows you to repeatedly apply the same operation with different
arguments stack_args[i]
. For each application of the layer, stack
creates
a new scope appended with an increasing number. For example:
y = stack(x, fully_connected, [32, 64, 128], scope='fc')
# It is equivalent to:
x = fully_connected(x, 32, scope='fc/fc_1')
x = fully_connected(x, 64, scope='fc/fc_2')
y = fully_connected(x, 128, scope='fc/fc_3')
If the scope
argument is not given in kwargs
, it is set to
layer.__name__
, or layer.func.__name__
(for functools.partial
objects). If neither __name__
nor func.__name__
is available, the
layers are called with scope='stack'
.
Args |
inputs
|
A Tensor suitable for layer.
|
layer
|
A layer with arguments (inputs, *args, **kwargs)
|
stack_args
|
A list/tuple of parameters for each call of layer.
|
**kwargs
|
Extra kwargs for the layer.
|
Returns |
A Tensor result of applying the stacked layers.
|
Raises |
ValueError
|
If the op is unknown or wrong.
|
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.layers.stack\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/layers/python/layers/layers.py#L3010-L3062) |\n\nBuilds a stack of layers by applying layer repeatedly using stack_args. \n\n tf.contrib.layers.stack(\n inputs, layer, stack_args, **kwargs\n )\n\n`stack` allows you to repeatedly apply the same operation with different\narguments `stack_args[i]`. For each application of the layer, `stack` creates\na new scope appended with an increasing number. For example: \n\n y = stack(x, fully_connected, [32, 64, 128], scope='fc')\n # It is equivalent to:\n\n x = fully_connected(x, 32, scope='fc/fc_1')\n x = fully_connected(x, 64, scope='fc/fc_2')\n y = fully_connected(x, 128, scope='fc/fc_3')\n\nIf the `scope` argument is not given in `kwargs`, it is set to\n`layer.__name__`, or `layer.func.__name__` (for `functools.partial`\nobjects). If neither `__name__` nor `func.__name__` is available, the\nlayers are called with `scope='stack'`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|----------------------------------------------------|\n| `inputs` | A `Tensor` suitable for layer. |\n| `layer` | A layer with arguments `(inputs, *args, **kwargs)` |\n| `stack_args` | A list/tuple of parameters for each call of layer. |\n| `**kwargs` | Extra kwargs for the layer. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` result of applying the stacked layers. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------|\n| `ValueError` | If the op is unknown or wrong. |\n\n\u003cbr /\u003e"]]