string_tensor: A Tensor
of type string
.
out_type: An optional tf.DType
from: tf.float32, tf.int32
. Defaults to tf.float32
.
The numeric type to interpret each string in string_tensor as.
name: A name for the operation (optional).
Returns:
A Tensor
of type out_type
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sub(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sub, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sub
Return
Applicative
Origial documentation for Builder.sub
def sub(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sub
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.sub
def sub(x, y, name=None)
Returns x - y element-wise.
NOTE: Sub
supports broadcasting. More about broadcasting
here
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
y: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sub_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sub_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sub_layer
Return
Applicative
Origial documentation for Builder.sub_layer
def sub_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sub, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.sub
def sub(x, y, name=None):
Returns x - y element-wise.
NOTE: Sub
supports broadcasting. More about broadcasting
here
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
y: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sufficient_statistics(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sufficient_statistics, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sufficient_statistics
Return
Applicative
Origial documentation for Builder.sufficient_statistics
def sufficient_statistics(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.sufficient_statistics
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.sufficient_statistics
def sufficient_statistics(x, axes, shift=None, keep_dims=False, name=None)
Calculate the sufficient statistics for the mean and variance of x
.
These sufficient statistics are computed using the one pass algorithm on an input that's optionally shifted. See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Computing_shifted_data
Args:
x: A Tensor
.
axes: Array of ints. Axes along which to compute mean and variance.
shift: A Tensor
containing the value by which to shift the data for
numerical stability, or None
if no shift is to be performed. A shift
close to the true mean provides the most numerically stable results.
keep_dims: produce statistics with the same dimensionality as the input.
name: Name used to scope the operations that compute the sufficient stats.
Returns:
Four Tensor
objects of the same type as x
:
* the count (number of elements to average over).
* the (possibly shifted) sum of the elements in the array.
* the (possibly shifted) sum of squares of the elements in the array.
* the shift by which the mean must be corrected or None if shift
is None.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sufficient_statistics_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sufficient_statistics_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sufficient_statistics_layer
Return
Applicative
Origial documentation for Builder.sufficient_statistics_layer
def sufficient_statistics_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.sufficient_statistics, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.sufficient_statistics
def sufficient_statistics(x, axes, shift=None, keep_dims=False, name=None):
Calculate the sufficient statistics for the mean and variance of x
.
These sufficient statistics are computed using the one pass algorithm on an input that's optionally shifted. See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Computing_shifted_data
Args:
x: A Tensor
.
axes: Array of ints. Axes along which to compute mean and variance.
shift: A Tensor
containing the value by which to shift the data for
numerical stability, or None
if no shift is to be performed. A shift
close to the true mean provides the most numerically stable results.
keep_dims: produce statistics with the same dimensionality as the input.
name: Name used to scope the operations that compute the sufficient stats.
Returns:
Four Tensor
objects of the same type as x
:
* the count (number of elements to average over).
* the (possibly shifted) sum of the elements in the array.
* the (possibly shifted) sum of squares of the elements in the array.
* the shift by which the mean must be corrected or None if shift
is None.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def svd(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.svd, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.svd
Return
Applicative
Origial documentation for Builder.svd
def svd(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.svd
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.svd
def svd(tensor, compute_uv=True, full_matrices=False, name=None)
Computes the singular value decompositions of one or more matrices.
Computes the SVD of each inner matrix in tensor
such that
tensor[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(v[..., :,
:])
```prettyprint
a is a tensor.
s is a tensor of singular values.
u is a tensor of left singular vectors.
v is a tensor of right singular vectors.
s, u, v = svd(a) s = svd(a, compute_uv=False) ```
Args:
matrix: Tensor
of shape [..., M, N]
. Let P
be the minimum of M
and
N
.
compute_uv: If True
then left and right singular vectors will be
computed and returned in u
and v
, respectively. Otherwise, only the
singular values will be computed, which can be significantly faster.
full_matrices: If true, compute full-sized u
and v
. If false
(the default), compute only the leading P
singular vectors.
Ignored if compute_uv
is False
.
name: string, optional name of the operation.
Returns:
s: Singular values. Shape is [..., P]
.
u: Right singular vectors. If full_matrices
is False
(default) then
shape is [..., M, P]
; if full_matrices
is True
then shape is
[..., M, M]
. Not returned if compute_uv
is False
.
v: Left singular vectors. If full_matrices
is False
(default) then
shape is [..., N, P]
. If full_matrices
is True
then shape is
[..., N, N]
. Not returned if compute_uv
is False
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def svd_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.svd_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.svd_layer
Return
Applicative
Origial documentation for Builder.svd_layer
def svd_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.svd, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.svd
def svd(tensor, compute_uv=True, full_matrices=False, name=None):
Computes the singular value decompositions of one or more matrices.
Computes the SVD of each inner matrix in tensor
such that
tensor[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(v[..., :,
:])
```prettyprint
a is a tensor.
s is a tensor of singular values.
u is a tensor of left singular vectors.
v is a tensor of right singular vectors.
s, u, v = svd(a) s = svd(a, compute_uv=False) ```
Args:
matrix: Tensor
of shape [..., M, N]
. Let P
be the minimum of M
and
N
.
compute_uv: If True
then left and right singular vectors will be
computed and returned in u
and v
, respectively. Otherwise, only the
singular values will be computed, which can be significantly faster.
full_matrices: If true, compute full-sized u
and v
. If false
(the default), compute only the leading P
singular vectors.
Ignored if compute_uv
is False
.
name: string, optional name of the operation.
Returns:
s: Singular values. Shape is [..., P]
.
u: Right singular vectors. If full_matrices
is False
(default) then
shape is [..., M, P]
; if full_matrices
is True
then shape is
[..., M, M]
. Not returned if compute_uv
is False
.
v: Left singular vectors. If full_matrices
is False
(default) then
shape is [..., N, P]
. If full_matrices
is True
then shape is
[..., N, N]
. Not returned if compute_uv
is False
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tan(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tan, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tan
Return
Applicative
Origial documentation for Builder.tan
def tan(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.tan
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.tan
def tan(x, name=None)
Computes tan of x element-wise.
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tan_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tan_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tan_layer
Return
Applicative
Origial documentation for Builder.tan_layer
def tan_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.tan, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.tan
def tan(x, name=None):
Computes tan of x element-wise.
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tanh(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tanh, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tanh
Return
Applicative
Origial documentation for Builder.tanh
def tanh(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.tanh
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.tanh
def tanh(x, name=None)
Computes hyperbolic tangent of x
element-wise.
Args:
x: A Tensor or SparseTensor with type float
, double
, int32
,
complex64
, int64
, or qint32
.
name: A name for the operation (optional).
Returns:
A Tensor or SparseTensor respectively with the same type as x
if
x.dtype != qint32
otherwise the return type is quint8
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tanh_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tanh_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tanh_layer
Return
Applicative
Origial documentation for Builder.tanh_layer
def tanh_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.tanh, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.tanh
def tanh(x, name=None):
Computes hyperbolic tangent of x
element-wise.
Args:
x: A Tensor or SparseTensor with type float
, double
, int32
,
complex64
, int64
, or qint32
.
name: A name for the operation (optional).
Returns:
A Tensor or SparseTensor respectively with the same type as x
if
x.dtype != qint32
otherwise the return type is quint8
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tensor(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tensor, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tensor
Return
Applicative
Origial documentation for Builder.tensor
def tensor(self):
Returns the Tensor contianed by the Builder
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tensors(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(BuilderTree.tensors, ...)
Arguments
- All other *args and **kwargs are forwarded to
BuilderTree.tensors
Return
Applicative
Origial documentation for BuilderTree.tensors
def tensors(self):
Same as tensorbuilder.core.builders.BuilderTree.builders
but extracts the tensor from each tensorbuilder.core.builders.Builder
.
Return
list( tf.Tensor )
Example
This examples creates a network to that solves the XOR problem using sigmoid units
import tensorflow as tf from tensorbuilder import tb x = tf.placeholder(tf.float32, shape=[None, 2]) y = tf.placeholder(tf.float32, shape=[None, 1]) #Network [activation_tensor, trainer_tensor] = ( tb.build(x) .sigmoid_layer(2) .linear_layer(1) .branch(lambda logit: [ logit.sigmoid() # activation , logit .sigmoid_cross_entropy_with_logits(y) # loss .map(tf.train.AdamOptimizer(0.01).minimize) # trainer ]) .tensors() )
Same example using the DSL
import tensorflow as tf from tensorbuilder import tb x = tf.placeholder(tf.float32, shape=[None, 2]) y = tf.placeholder(tf.float32, shape=[None, 1]) #Network [activation_tensor, trainer_tensor] = tb.pipe( x, tb.sigmoid_layer(2) .linear_layer(1), [ tb.sigmoid() # activation , tb .sigmoid_cross_entropy_with_logits(y) # loss .map(tf.train.AdamOptimizer(0.01).minimize) # trainer ], tb.tensors() )
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def then(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.then, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.then
Return
Applicative
Origial documentation for Builder.then
def then(builder, fn):
@immutable
Expects a function fn with type builder -> builder
. This method is used primarily to manupilate the Builder with very fine grain control through the fluent immutable API.
Parameters
fn
: a function of typebuilder -> builder
.
Return
tensorbuilder.core.builders.Builder
Example
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def then_with(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.then_with, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.then_with
Return
Applicative
Origial documentation for Builder.then_with
def then_with(builder, scope_fn):
@immutable
Expects a function fn with that returns a "Disposable" (implement __enter__
and __exit__
) plus some *args and **kwargs, and return a function g
that expects a function h
of type Builder -> Builder
such that
.then_with(fn, *args, **kwargs)(h)
roughly perform this computations (given the current builder
)
with fn(*args, **kwargs): return h(builder)
For a more practical understanding look at the example.
Parameters
fn
: a function of typeBuilder -> Disposable
.
Return
- Function of type
(Builder -> Builder)
Examples
Create a network with 3 branches and execute each on the devices "/gpu:0", "/gpu:1", "cpu:3" respectively
import tensorflow as tf from tensorbuilder import tb x = placeholder(tf.float32, shape=[None, 10]) h = ( tb.build(x) .branch(lambda x: [ x.then_with(tf.device, "/gpu:0")(lambda x: x.relu_layer(20) .linear_layer(5) ) , x.then_with(tf.device, "/gpu:1")(lambda x: x.sigmoid_layer(20) .linear_layer(5) ) , x.then_with(tf.device, "/cpu:0")(lambda x: x.tanh_layer(20) .linear_layer(5) ) ]) .reduce(tf.add) .softmax() .tensor() )
This looks much better with the DSL thanks to its support for scopes
import tensorflow as tf from tensorbuilder import tb x = placeholder(tf.float32, shape=[None, 10]) h = tb.pipe( x, [ { tf.device("/gpu:0"): tb.relu_layer(20) .linear_layer(5) } , { tf.device("/gpu:1"): tb.sigmoid_layer(20) .linear_layer(5) } , { tf.device("/cpu:0"): tb.tanh_layer(20) .linear_layer(5) } ], tb.reduce(tf.add) .softmax() .tensor() )
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tile(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tile, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tile
Return
Applicative
Origial documentation for Builder.tile
def tile(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.tile
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.tile
def tile(input, multiples, name=None)
Constructs a tensor by tiling a given tensor.
This operation creates a new tensor by replicating input
multiples
times.
The output tensor's i'th dimension has input.dims(i) * multiples[i]
elements,
and the values of input
are replicated multiples[i]
times along the 'i'th
dimension. For example, tiling [a b c d]
by [2]
produces
[a b c d a b c d]
.
Args:
input: A Tensor
. 1-D or higher.
multiples: A Tensor
. Must be one of the following types: int32
, int64
.
1-D. Length must be the same as the number of dimensions in input
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as input
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tile_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tile_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tile_layer
Return
Applicative
Origial documentation for Builder.tile_layer
def tile_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.tile, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.tile
def tile(input, multiples, name=None):
Constructs a tensor by tiling a given tensor.
This operation creates a new tensor by replicating input
multiples
times.
The output tensor's i'th dimension has input.dims(i) * multiples[i]
elements,
and the values of input
are replicated multiples[i]
times along the 'i'th
dimension. For example, tiling [a b c d]
by [2]
produces
[a b c d a b c d]
.
Args:
input: A Tensor
. 1-D or higher.
multiples: A Tensor
. Must be one of the following types: int32
, int64
.
1-D. Length must be the same as the number of dimensions in input
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as input
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_bfloat16(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_bfloat16, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_bfloat16
Return
Applicative
Origial documentation for Builder.to_bfloat16
def to_bfloat16(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.to_bfloat16
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.to_bfloat16
def to_bfloat16(x, name="ToBFloat16")
Casts a tensor to type bfloat16
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type bfloat16
.
Raises:
TypeError: If x
cannot be cast to the bfloat16
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_bfloat16_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_bfloat16_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_bfloat16_layer
Return
Applicative
Origial documentation for Builder.to_bfloat16_layer
def to_bfloat16_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.to_bfloat16, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.to_bfloat16
def to_bfloat16(x, name="ToBFloat16"):
Casts a tensor to type bfloat16
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type bfloat16
.
Raises:
TypeError: If x
cannot be cast to the bfloat16
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_double(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_double, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_double
Return
Applicative
Origial documentation for Builder.to_double
def to_double(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.to_double
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.to_double
def to_double(x, name="ToDouble")
Casts a tensor to type float64
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type float64
.
Raises:
TypeError: If x
cannot be cast to the float64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_double_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_double_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_double_layer
Return
Applicative
Origial documentation for Builder.to_double_layer
def to_double_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.to_double, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.to_double
def to_double(x, name="ToDouble"):
Casts a tensor to type float64
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type float64
.
Raises:
TypeError: If x
cannot be cast to the float64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_float(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_float, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_float
Return
Applicative
Origial documentation for Builder.to_float
def to_float(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.to_float
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.to_float
def to_float(x, name="ToFloat")
Casts a tensor to type float32
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type float32
.
Raises:
TypeError: If x
cannot be cast to the float32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_float_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_float_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_float_layer
Return
Applicative
Origial documentation for Builder.to_float_layer
def to_float_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.to_float, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.to_float
def to_float(x, name="ToFloat"):
Casts a tensor to type float32
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type float32
.
Raises:
TypeError: If x
cannot be cast to the float32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_int32(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_int32, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_int32
Return
Applicative
Origial documentation for Builder.to_int32
def to_int32(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.to_int32
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.to_int32
def to_int32(x, name="ToInt32")
Casts a tensor to type int32
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type int32
.
Raises:
TypeError: If x
cannot be cast to the int32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_int32_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_int32_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_int32_layer
Return
Applicative
Origial documentation for Builder.to_int32_layer
def to_int32_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.to_int32, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.to_int32
def to_int32(x, name="ToInt32"):
Casts a tensor to type int32
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type int32
.
Raises:
TypeError: If x
cannot be cast to the int32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_int64(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_int64, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_int64
Return
Applicative
Origial documentation for Builder.to_int64
def to_int64(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.to_int64
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.to_int64
def to_int64(x, name="ToInt64")
Casts a tensor to type int64
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type int64
.
Raises:
TypeError: If x
cannot be cast to the int64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def to_int64_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.to_int64_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.to_int64_layer
Return
Applicative
Origial documentation for Builder.to_int64_layer
def to_int64_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.to_int64, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.to_int64
def to_int64(x, name="ToInt64"):
Casts a tensor to type int64
.
Args:
x: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
with same shape as x
with type int64
.
Raises:
TypeError: If x
cannot be cast to the int64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def top_k(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.top_k, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.top_k
Return
Applicative
Origial documentation for Builder.top_k
def top_k(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.top_k
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.top_k
def top_k(input, k=1, sorted=True, name=None)
Finds values and indices of the k
largest entries for the last dimension.
If the input is a vector (rank-1), finds the k
largest entries in the vector
and outputs their values and indices as vectors. Thus values[j]
is the
j
-th largest entry in input
, and its index is indices[j]
.
For matrices (resp. higher rank input), computes the top k
entries in each
row (resp. vector along the last dimension). Thus,
values.shape = indices.shape = input.shape[:-1] + [k]
If two elements are equal, the lower-index element appears first.
Args:
input: 1-D or higher Tensor
with last dimension at least k
.
k: 0-D int32
Tensor
. Number of top elements to look for along the last
dimension (along each row for matrices).
sorted: If true the resulting k
elements will be sorted by the values in
descending order.
name: Optional name for the operation.
Returns:
values: The k
largest elements along each last dimensional slice.
indices: The indices of values
within the last dimension of input
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def top_k_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.top_k_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.top_k_layer
Return
Applicative
Origial documentation for Builder.top_k_layer
def top_k_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.top_k, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.top_k
def top_k(input, k=1, sorted=True, name=None):
Finds values and indices of the k
largest entries for the last dimension.
If the input is a vector (rank-1), finds the k
largest entries in the vector
and outputs their values and indices as vectors. Thus values[j]
is the
j
-th largest entry in input
, and its index is indices[j]
.
For matrices (resp. higher rank input), computes the top k
entries in each
row (resp. vector along the last dimension). Thus,
values.shape = indices.shape = input.shape[:-1] + [k]
If two elements are equal, the lower-index element appears first.
Args:
input: 1-D or higher Tensor
with last dimension at least k
.
k: 0-D int32
Tensor
. Number of top elements to look for along the last
dimension (along each row for matrices).
sorted: If true the resulting k
elements will be sorted by the values in
descending order.
name: Optional name for the operation.
Returns:
values: The k
largest elements along each last dimensional slice.
indices: The indices of values
within the last dimension of input
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def trace(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.trace, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.trace
Return
Applicative
Origial documentation for Builder.trace
def trace(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.trace
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.trace
def trace(x, name=None)
Compute the trace of a tensor x
.
trace(x)
returns the sum of along the diagonal.
For example:
```python
'x' is [[1, 1],
[1, 1]]
tf.trace(x) ==> 2
'x' is [[1,2,3],
[4,5,6],
[7,8,9]]
tf.trace(x) ==> 15 ```
Args: x: 2-D tensor. name: A name for the operation (optional).
Returns: The trace of input tensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def trace_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.trace_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.trace_layer
Return
Applicative
Origial documentation for Builder.trace_layer
def trace_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.trace, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.trace
def trace(x, name=None):
Compute the trace of a tensor x
.
trace(x)
returns the sum of along the diagonal.
For example:
```python
'x' is [[1, 1],
[1, 1]]
tf.trace(x) ==> 2
'x' is [[1,2,3],
[4,5,6],
[7,8,9]]
tf.trace(x) ==> 15 ```
Args: x: 2-D tensor. name: A name for the operation (optional).
Returns: The trace of input tensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def trainable_variables(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.trainable_variables, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.trainable_variables
Return
Applicative
Origial documentation for Builder.trainable_variables
def trainable_variables(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.trainable_variables
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.trainable_variables
def trainable_variables()
Returns all variables created with trainable=True
.
When passed trainable=True
, the Variable()
constructor automatically
adds new variables to the graph collection
GraphKeys.TRAINABLE_VARIABLES
. This convenience function returns the
contents of that collection.
Returns: A list of Variable objects.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def trainable_variables_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.trainable_variables_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.trainable_variables_layer
Return
Applicative
Origial documentation for Builder.trainable_variables_layer
def trainable_variables_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.trainable_variables, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.trainable_variables
def trainable_variables():
Returns all variables created with trainable=True
.
When passed trainable=True
, the Variable()
constructor automatically
adds new variables to the graph collection
GraphKeys.TRAINABLE_VARIABLES
. This convenience function returns the
contents of that collection.
Returns: A list of Variable objects.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def transpose(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.transpose, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.transpose
Return
Applicative
Origial documentation for Builder.transpose
def transpose(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.transpose
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.transpose
def transpose(a, perm=None, name="transpose")
Transposes a
. Permutes the dimensions according to perm
.
The returned tensor's dimension i will correspond to the input dimension
perm[i]
. If perm
is not given, it is set to (n-1...0), where n is
the rank of the input tensor. Hence by default, this operation performs a
regular matrix transpose on 2-D input Tensors.
For example:
```python
'x' is [[1 2 3]
[4 5 6]]
tf.transpose(x) ==> [[1 4] [2 5] [3 6]]
Equivalently
tf.transpose(x, perm=[1, 0]) ==> [[1 4] [2 5] [3 6]]
'perm' is more useful for n-dimensional tensors, for n > 2
'x' is [[[1 2 3]
[4 5 6]]
[[7 8 9]
[10 11 12]]]
Take the transpose of the matrices in dimension-0
tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4] [2 5] [3 6]]
[[7 10] [8 11] [9 12]]]
```
Args:
a: A Tensor
.
perm: A permutation of the dimensions of a
.
name: A name for the operation (optional).
Returns:
A transposed Tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def transpose_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.transpose_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.transpose_layer
Return
Applicative
Origial documentation for Builder.transpose_layer
def transpose_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.transpose, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.transpose
def transpose(a, perm=None, name="transpose"):
Transposes a
. Permutes the dimensions according to perm
.
The returned tensor's dimension i will correspond to the input dimension
perm[i]
. If perm
is not given, it is set to (n-1...0), where n is
the rank of the input tensor. Hence by default, this operation performs a
regular matrix transpose on 2-D input Tensors.
For example:
```python
'x' is [[1 2 3]
[4 5 6]]
tf.transpose(x) ==> [[1 4] [2 5] [3 6]]
Equivalently
tf.transpose(x, perm=[1, 0]) ==> [[1 4] [2 5] [3 6]]
'perm' is more useful for n-dimensional tensors, for n > 2
'x' is [[[1 2 3]
[4 5 6]]
[[7 8 9]
[10 11 12]]]
Take the transpose of the matrices in dimension-0
tf.transpose(x, perm=[0, 2, 1]) ==> [[[1 4] [2 5] [3 6]]
[[7 10] [8 11] [9 12]]]
```
Args:
a: A Tensor
.
perm: A permutation of the dimensions of a
.
name: A name for the operation (optional).
Returns:
A transposed Tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truediv(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truediv, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truediv
Return
Applicative
Origial documentation for Builder.truediv
def truediv(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.truediv
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.truediv
def truediv(x, y, name=None)
Divides x / y elementwise, always producing floating point results.
The same as tf.div
for floating point arguments, but casts integer arguments
to floating point before dividing so that the result is always floating point.
This op is generated by normal x / y
division in Python 3 and in Python 2.7
with from __future__ import division
. If you want integer division that
rounds down, use x // y
or tf.floordiv
.
x
and y
must have the same numeric type. If the inputs are floating
point, the output will have the same type. If the inputs are integral, the
inputs are cast to float32
for int8
and int16
and float64
for int32
and int64
(matching the behavior of Numpy).
Args:
x: Tensor
numerator of numeric type.
y: Tensor
denominator of numeric type.
name: A name for the operation (optional).
Returns:
x / y
evaluated in floating point.
Raises:
TypeError: If x
and y
have different dtypes.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truediv_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truediv_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truediv_layer
Return
Applicative
Origial documentation for Builder.truediv_layer
def truediv_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.truediv, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.truediv
def truediv(x, y, name=None):
Divides x / y elementwise, always producing floating point results.
The same as tf.div
for floating point arguments, but casts integer arguments
to floating point before dividing so that the result is always floating point.
This op is generated by normal x / y
division in Python 3 and in Python 2.7
with from __future__ import division
. If you want integer division that
rounds down, use x // y
or tf.floordiv
.
x
and y
must have the same numeric type. If the inputs are floating
point, the output will have the same type. If the inputs are integral, the
inputs are cast to float32
for int8
and int16
and float64
for int32
and int64
(matching the behavior of Numpy).
Args:
x: Tensor
numerator of numeric type.
y: Tensor
denominator of numeric type.
name: A name for the operation (optional).
Returns:
x / y
evaluated in floating point.
Raises:
TypeError: If x
and y
have different dtypes.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truncated_normal(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truncated_normal, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truncated_normal
Return
Applicative
Origial documentation for Builder.truncated_normal
def truncated_normal(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.truncated_normal
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.truncated_normal
def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=<dtype: 'float32'>, seed=None, name=None)
Outputs random values from a truncated normal distribution.
The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than 2 standard deviations from the mean are dropped and re-picked.
Args:
shape: A 1-D integer Tensor or Python array. The shape of the output tensor.
mean: A 0-D Tensor or Python value of type dtype
. The mean of the
truncated normal distribution.
stddev: A 0-D Tensor or Python value of type dtype
. The standard deviation
of the truncated normal distribution.
dtype: The type of the output.
seed: A Python integer. Used to create a random seed for the distribution.
See
set_random_seed
for behavior.
name: A name for the operation (optional).
Returns: A tensor of the specified shape filled with random truncated normal values.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truncated_normal_initializer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truncated_normal_initializer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truncated_normal_initializer
Return
Applicative
Origial documentation for Builder.truncated_normal_initializer
def truncated_normal_initializer(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.truncated_normal_initializer
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.truncated_normal_initializer
def truncated_normal_initializer(mean=0.0, stddev=1.0, seed=None, dtype=<dtype: 'float32'>)
Returns an initializer that generates a truncated normal distribution.
These values are similar to values from a random_normal_initializer
except that values more than two standard deviations from the mean
are discarded and re-drawn. This is the recommended initializer for
neural network weights and filters.
Args:
mean: a python scalar or a scalar tensor. Mean of the random values
to generate.
stddev: a python scalar or a scalar tensor. Standard deviation of the
random values to generate.
seed: A Python integer. Used to create random seeds. See
set_random_seed
for behavior.
dtype: The data type. Only floating point types are supported.
Returns: An initializer that generates tensors with a truncated normal distribution.
Raises:
ValueError: if dtype
is not a floating point type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truncated_normal_initializer_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truncated_normal_initializer_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truncated_normal_initializer_layer
Return
Applicative
Origial documentation for Builder.truncated_normal_initializer_layer
def truncated_normal_initializer_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.truncated_normal_initializer, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.truncated_normal_initializer
def truncated_normal_initializer(mean=0.0, stddev=1.0, seed=None, dtype=<dtype: 'float32'>):
Returns an initializer that generates a truncated normal distribution.
These values are similar to values from a random_normal_initializer
except that values more than two standard deviations from the mean
are discarded and re-drawn. This is the recommended initializer for
neural network weights and filters.
Args:
mean: a python scalar or a scalar tensor. Mean of the random values
to generate.
stddev: a python scalar or a scalar tensor. Standard deviation of the
random values to generate.
seed: A Python integer. Used to create random seeds. See
set_random_seed
for behavior.
dtype: The data type. Only floating point types are supported.
Returns: An initializer that generates tensors with a truncated normal distribution.
Raises:
ValueError: if dtype
is not a floating point type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def truncated_normal_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.truncated_normal_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.truncated_normal_layer
Return
Applicative
Origial documentation for Builder.truncated_normal_layer
def truncated_normal_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.truncated_normal, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.truncated_normal
def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=<dtype: 'float32'>, seed=None, name=None):
Outputs random values from a truncated normal distribution.
The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than 2 standard deviations from the mean are dropped and re-picked.
Args:
shape: A 1-D integer Tensor or Python array. The shape of the output tensor.
mean: A 0-D Tensor or Python value of type dtype
. The mean of the
truncated normal distribution.
stddev: A 0-D Tensor or Python value of type dtype
. The standard deviation
of the truncated normal distribution.
dtype: The type of the output.
seed: A Python integer. Used to create a random seed for the distribution.
See
set_random_seed
for behavior.
name: A name for the operation (optional).
Returns: A tensor of the specified shape filled with random truncated normal values.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tuple(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tuple, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tuple
Return
Applicative
Origial documentation for Builder.tuple
def tuple(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.tuple
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.tuple
def tuple(tensors, name=None, control_inputs=None)
Group tensors together.
This creates a tuple of tensors with the same values as the tensors
argument, except that the value of each tensor is only returned after the
values of all tensors have been computed.
control_inputs
contains additional ops that have to finish before this op
finishes, but whose outputs are not returned.
This can be used as a "join" mechanism for parallel computations: all the
argument tensors can be computed in parallel, but the values of any tensor
returned by tuple
are only available after all the parallel computations
are done.
See also group
and with_dependencies
.
Args:
tensors: A list of Tensor
s or IndexedSlices
, some entries can be None
.
name: (optional) A name to use as a name_scope
for the operation.
control_inputs: List of additional ops to finish before returning.
Returns:
Same as tensors
.
Raises:
ValueError: If tensors
does not contain any Tensor
or IndexedSlices
.
TypeError: If control_inputs
is not a list of Operation
or Tensor
objects.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def tuple_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.tuple_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.tuple_layer
Return
Applicative
Origial documentation for Builder.tuple_layer
def tuple_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.tuple, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.tuple
def tuple(tensors, name=None, control_inputs=None):
Group tensors together.
This creates a tuple of tensors with the same values as the tensors
argument, except that the value of each tensor is only returned after the
values of all tensors have been computed.
control_inputs
contains additional ops that have to finish before this op
finishes, but whose outputs are not returned.
This can be used as a "join" mechanism for parallel computations: all the
argument tensors can be computed in parallel, but the values of any tensor
returned by tuple
are only available after all the parallel computations
are done.
See also group
and with_dependencies
.
Args:
tensors: A list of Tensor
s or IndexedSlices
, some entries can be None
.
name: (optional) A name to use as a name_scope
for the operation.
control_inputs: List of additional ops to finish before returning.
Returns:
Same as tensors
.
Raises:
ValueError: If tensors
does not contain any Tensor
or IndexedSlices
.
TypeError: If control_inputs
is not a list of Operation
or Tensor
objects.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def uniform_candidate_sampler(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.uniform_candidate_sampler, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.uniform_candidate_sampler
Return
Applicative
Origial documentation for Builder.uniform_candidate_sampler
def uniform_candidate_sampler(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.uniform_candidate_sampler
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.uniform_candidate_sampler
def uniform_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None)
Samples a set of classes using a uniform base distribution.
This operation randomly samples a tensor of sampled classes
(sampled_candidates
) from the range of integers [0, range_max)
.
The elements of sampled_candidates
are drawn without replacement
(if unique=True
) or with replacement (if unique=False
) from
the base distribution.
The base distribution for this operation is the uniform distribution
over the range of integers [0, range_max)
.
In addition, this operation returns tensors true_expected_count
and sampled_expected_count
representing the number of times each
of the target classes (true_classes
) and the sampled
classes (sampled_candidates
) is expected to occur in an average
tensor of sampled classes. These values correspond to Q(y|x)
defined in this
document.
If unique=True
, then these are post-rejection probabilities and we
compute them approximately.
Args:
true_classes: A Tensor
of type int64
and shape [batch_size,
num_true]
. The target classes.
num_true: An int
. The number of target classes per training example.
num_sampled: An int
. The number of classes to randomly sample per batch.
unique: A bool
. Determines whether all sampled classes in a batch are
unique.
range_max: An int
. The number of possible classes.
seed: An int
. An operation-specific seed. Default is 0.
name: A name for the operation (optional).
Returns:
sampled_candidates: A tensor of type int64
and shape [num_sampled]
.
The sampled classes.
true_expected_count: A tensor of type float
. Same shape as
true_classes
. The expected counts under the sampling distribution
of each of true_classes
.
sampled_expected_count: A tensor of type float
. Same shape as
sampled_candidates
. The expected counts under the sampling distribution
of each of sampled_candidates
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def uniform_candidate_sampler_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.uniform_candidate_sampler_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.uniform_candidate_sampler_layer
Return
Applicative
Origial documentation for Builder.uniform_candidate_sampler_layer
def uniform_candidate_sampler_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.uniform_candidate_sampler, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.uniform_candidate_sampler
def uniform_candidate_sampler(true_classes, num_true, num_sampled, unique, range_max, seed=None, name=None):
Samples a set of classes using a uniform base distribution.
This operation randomly samples a tensor of sampled classes
(sampled_candidates
) from the range of integers [0, range_max)
.
The elements of sampled_candidates
are drawn without replacement
(if unique=True
) or with replacement (if unique=False
) from
the base distribution.
The base distribution for this operation is the uniform distribution
over the range of integers [0, range_max)
.
In addition, this operation returns tensors true_expected_count
and sampled_expected_count
representing the number of times each
of the target classes (true_classes
) and the sampled
classes (sampled_candidates
) is expected to occur in an average
tensor of sampled classes. These values correspond to Q(y|x)
defined in this
document.
If unique=True
, then these are post-rejection probabilities and we
compute them approximately.
Args:
true_classes: A Tensor
of type int64
and shape [batch_size,
num_true]
. The target classes.
num_true: An int
. The number of target classes per training example.
num_sampled: An int
. The number of classes to randomly sample per batch.
unique: A bool
. Determines whether all sampled classes in a batch are
unique.
range_max: An int
. The number of possible classes.
seed: An int
. An operation-specific seed. Default is 0.
name: A name for the operation (optional).
Returns:
sampled_candidates: A tensor of type int64
and shape [num_sampled]
.
The sampled classes.
true_expected_count: A tensor of type float
. Same shape as
true_classes
. The expected counts under the sampling distribution
of each of true_classes
.
sampled_expected_count: A tensor of type float
. Same shape as
sampled_candidates
. The expected counts under the sampling distribution
of each of sampled_candidates
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def uniform_unit_scaling_initializer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.uniform_unit_scaling_initializer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.uniform_unit_scaling_initializer
Return
Applicative
Origial documentation for Builder.uniform_unit_scaling_initializer
def uniform_unit_scaling_initializer(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.uniform_unit_scaling_initializer
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.uniform_unit_scaling_initializer
def uniform_unit_scaling_initializer(factor=1.0, seed=None, dtype=<dtype: 'float32'>)
Returns an initializer that generates tensors without scaling variance.
When initializing a deep network, it is in principle advantageous to keep
the scale of the input variance constant, so it does not explode or diminish
by reaching the final layer. If the input is x
and the operation x * W
,
and we want to initialize W
uniformly at random, we need to pick W
from
[-sqrt(3) / sqrt(dim), sqrt(3) / sqrt(dim)]
to keep the scale intact, where dim = W.shape[0]
(the size of the input).
A similar calculation for convolutional networks gives an analogous result
with dim
equal to the product of the first 3 dimensions. When
nonlinearities are present, we need to multiply this by a constant factor
.
See Sussillo et al., 2014
(pdf) for deeper motivation, experiments
and the calculation of constants. In section 2.3 there, the constants were
numerically computed: for a linear layer it's 1.0, relu: ~1.43, tanh: ~1.15.
Args:
factor: Float. A multiplicative factor by which the values will be scaled.
seed: A Python integer. Used to create random seeds. See
set_random_seed
for behavior.
dtype: The data type. Only floating point types are supported.
Returns: An initializer that generates tensors with unit variance.
Raises:
ValueError: if dtype
is not a floating point type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def uniform_unit_scaling_initializer_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.uniform_unit_scaling_initializer_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.uniform_unit_scaling_initializer_layer
Return
Applicative
Origial documentation for Builder.uniform_unit_scaling_initializer_layer
def uniform_unit_scaling_initializer_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.uniform_unit_scaling_initializer, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.uniform_unit_scaling_initializer
def uniform_unit_scaling_initializer(factor=1.0, seed=None, dtype=<dtype: 'float32'>):
Returns an initializer that generates tensors without scaling variance.
When initializing a deep network, it is in principle advantageous to keep
the scale of the input variance constant, so it does not explode or diminish
by reaching the final layer. If the input is x
and the operation x * W
,
and we want to initialize W
uniformly at random, we need to pick W
from
[-sqrt(3) / sqrt(dim), sqrt(3) / sqrt(dim)]
to keep the scale intact, where dim = W.shape[0]
(the size of the input).
A similar calculation for convolutional networks gives an analogous result
with dim
equal to the product of the first 3 dimensions. When
nonlinearities are present, we need to multiply this by a constant factor
.
See Sussillo et al., 2014
(pdf) for deeper motivation, experiments
and the calculation of constants. In section 2.3 there, the constants were
numerically computed: for a linear layer it's 1.0, relu: ~1.43, tanh: ~1.15.
Args:
factor: Float. A multiplicative factor by which the values will be scaled.
seed: A Python integer. Used to create random seeds. See
set_random_seed
for behavior.
dtype: The data type. Only floating point types are supported.
Returns: An initializer that generates tensors with unit variance.
Raises:
ValueError: if dtype
is not a floating point type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unique(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unique, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unique
Return
Applicative
Origial documentation for Builder.unique
def unique(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.unique
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.unique
def unique(x, out_idx=None, name=None)
Finds unique elements in a 1-D tensor.
This operation returns a tensor y
containing all of the unique elements of x
sorted in the same order that they occur in x
. This operation also returns a
tensor idx
the same size as x
that contains the index of each value of x
in the unique output y
. In other words:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
For example:
```prettyprint
tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] ```
Args:
x: A Tensor
. 1-D.
out_idx: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A tuple of Tensor
objects (y, idx).
y: A Tensor
. Has the same type as x
. 1-D.
idx: A Tensor
of type out_idx
. 1-D.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unique_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unique_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unique_layer
Return
Applicative
Origial documentation for Builder.unique_layer
def unique_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.unique, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.unique
def unique(x, out_idx=None, name=None):
Finds unique elements in a 1-D tensor.
This operation returns a tensor y
containing all of the unique elements of x
sorted in the same order that they occur in x
. This operation also returns a
tensor idx
the same size as x
that contains the index of each value of x
in the unique output y
. In other words:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
For example:
```prettyprint
tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx = unique(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] ```
Args:
x: A Tensor
. 1-D.
out_idx: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A tuple of Tensor
objects (y, idx).
y: A Tensor
. Has the same type as x
. 1-D.
idx: A Tensor
of type out_idx
. 1-D.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unique_with_counts(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unique_with_counts, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unique_with_counts
Return
Applicative
Origial documentation for Builder.unique_with_counts
def unique_with_counts(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.unique_with_counts
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.unique_with_counts
def unique_with_counts(x, out_idx=None, name=None)
Finds unique elements in a 1-D tensor.
This operation returns a tensor y
containing all of the unique elements of x
sorted in the same order that they occur in x
. This operation also returns a
tensor idx
the same size as x
that contains the index of each value of x
in the unique output y
. Finally, it returns a third tensor count
that
contains the count of each element of y
in x
. In other words:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
For example:
```prettyprint
tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx, count = unique_with_counts(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] count ==> [2, 1, 3, 1, 2] ```
Args:
x: A Tensor
. 1-D.
out_idx: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A tuple of Tensor
objects (y, idx, count).
y: A Tensor
. Has the same type as x
. 1-D.
idx: A Tensor
of type out_idx
. 1-D.
count: A Tensor
of type out_idx
. 1-D.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unique_with_counts_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unique_with_counts_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unique_with_counts_layer
Return
Applicative
Origial documentation for Builder.unique_with_counts_layer
def unique_with_counts_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.unique_with_counts, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.unique_with_counts
def unique_with_counts(x, out_idx=None, name=None):
Finds unique elements in a 1-D tensor.
This operation returns a tensor y
containing all of the unique elements of x
sorted in the same order that they occur in x
. This operation also returns a
tensor idx
the same size as x
that contains the index of each value of x
in the unique output y
. Finally, it returns a third tensor count
that
contains the count of each element of y
in x
. In other words:
y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]
For example:
```prettyprint
tensor 'x' is [1, 1, 2, 4, 4, 4, 7, 8, 8]
y, idx, count = unique_with_counts(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, 3, 4, 4] count ==> [2, 1, 3, 1, 2] ```
Args:
x: A Tensor
. 1-D.
out_idx: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A tuple of Tensor
objects (y, idx, count).
y: A Tensor
. Has the same type as x
. 1-D.
idx: A Tensor
of type out_idx
. 1-D.
count: A Tensor
of type out_idx
. 1-D.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unpack(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unpack, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unpack
Return
Applicative
Origial documentation for Builder.unpack
def unpack(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.unpack
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.unpack
def unpack(value, num=None, axis=0, name="unpack")
Unpacks the given dimension of a rank-R
tensor into rank-(R-1)
tensors.
Unpacks num
tensors from value
by chipping it along the axis
dimension.
If num
is not specified (the default), it is inferred from value
's shape.
If value.shape[axis]
is not known, ValueError
is raised.
For example, given a tensor of shape (A, B, C, D)
;
If axis == 0
then the i'th tensor in output
is the slice
value[i, :, :, :]
and each tensor in output
will have shape (B, C, D)
.
(Note that the dimension unpacked along is gone, unlike split
).
If axis == 1
then the i'th tensor in output
is the slice
value[:, i, :, :]
and each tensor in output
will have shape (A, C, D)
.
Etc.
This is the opposite of pack. The numpy equivalent is
tf.unpack(x, n) = list(x)
Args:
value: A rank R > 0
Tensor
to be unpacked.
num: An int
. The length of the dimension axis
. Automatically inferred
if None
(the default).
axis: An int
. The axis to unpack along. Defaults to the first
dimension. Supports negative indexes.
name: A name for the operation (optional).
Returns:
The list of Tensor
objects unpacked from value
.
Raises:
ValueError: If num
is unspecified and cannot be inferred.
ValueError: If axis
is out of the range [-R, R).
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unpack_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unpack_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unpack_layer
Return
Applicative
Origial documentation for Builder.unpack_layer
def unpack_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.unpack, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.unpack
def unpack(value, num=None, axis=0, name="unpack"):
Unpacks the given dimension of a rank-R
tensor into rank-(R-1)
tensors.
Unpacks num
tensors from value
by chipping it along the axis
dimension.
If num
is not specified (the default), it is inferred from value
's shape.
If value.shape[axis]
is not known, ValueError
is raised.
For example, given a tensor of shape (A, B, C, D)
;
If axis == 0
then the i'th tensor in output
is the slice
value[i, :, :, :]
and each tensor in output
will have shape (B, C, D)
.
(Note that the dimension unpacked along is gone, unlike split
).
If axis == 1
then the i'th tensor in output
is the slice
value[:, i, :, :]
and each tensor in output
will have shape (A, C, D)
.
Etc.
This is the opposite of pack. The numpy equivalent is
tf.unpack(x, n) = list(x)
Args:
value: A rank R > 0
Tensor
to be unpacked.
num: An int
. The length of the dimension axis
. Automatically inferred
if None
(the default).
axis: An int
. The axis to unpack along. Defaults to the first
dimension. Supports negative indexes.
name: A name for the operation (optional).
Returns:
The list of Tensor
objects unpacked from value
.
Raises:
ValueError: If num
is unspecified and cannot be inferred.
ValueError: If axis
is out of the range [-R, R).
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unsorted_segment_sum(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unsorted_segment_sum, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unsorted_segment_sum
Return
Applicative
Origial documentation for Builder.unsorted_segment_sum
def unsorted_segment_sum(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.unsorted_segment_sum
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.unsorted_segment_sum
def unsorted_segment_sum(data, segment_ids, num_segments, name=None)
Computes the sum along segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Computes a tensor such that
(output[i] = sum_{j...} data[j...]
where the sum is over tuples j...
such
that segment_ids[j...] == i
. Unlike SegmentSum
, segment_ids
need not be sorted and need not cover all values in the full
range of valid values.
If the sum is empty for a given segment ID i
, output[i] = 0
.
num_segments
should equal the number of distinct segment IDs.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
, int64
, int32
, uint8
, uint16
, int16
, int8
, complex64
, complex128
, qint8
, quint8
, qint32
, half
.
segment_ids: A Tensor
. Must be one of the following types: int32
, int64
.
A tensor whose shape is a prefix of data.shape
.
num_segments: A Tensor
of type int32
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as data
.
Has same shape as data, except for the first segment_ids.rank
dimensions, which are replaced with a single dimension which has size
num_segments
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def unsorted_segment_sum_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.unsorted_segment_sum_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.unsorted_segment_sum_layer
Return
Applicative
Origial documentation for Builder.unsorted_segment_sum_layer
def unsorted_segment_sum_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.unsorted_segment_sum, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.unsorted_segment_sum
def unsorted_segment_sum(data, segment_ids, num_segments, name=None):
Computes the sum along segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Computes a tensor such that
(output[i] = sum_{j...} data[j...]
where the sum is over tuples j...
such
that segment_ids[j...] == i
. Unlike SegmentSum
, segment_ids
need not be sorted and need not cover all values in the full
range of valid values.
If the sum is empty for a given segment ID i
, output[i] = 0
.
num_segments
should equal the number of distinct segment IDs.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
, int64
, int32
, uint8
, uint16
, int16
, int8
, complex64
, complex128
, qint8
, quint8
, qint32
, half
.
segment_ids: A Tensor
. Must be one of the following types: int32
, int64
.
A tensor whose shape is a prefix of data.shape
.
num_segments: A Tensor
of type int32
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as data
.
Has same shape as data, except for the first segment_ids.rank
dimensions, which are replaced with a single dimension which has size
num_segments
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def variable_axis_size_partitioner(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.variable_axis_size_partitioner, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.variable_axis_size_partitioner
Return
Applicative
Origial documentation for Builder.variable_axis_size_partitioner
def variable_axis_size_partitioner(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.variable_axis_size_partitioner
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.variable_axis_size_partitioner
def variable_axis_size_partitioner(max_shard_bytes, axis=0, bytes_per_string_element=16, max_shards=None)
Get a partitioner for VariableScope to keep shards below max_shard_bytes
.
This partitioner will shard a Variable along one axis, attempting to keep
the maximum shard size below max_shard_bytes
. In practice, this is not
always possible when sharding along only one axis. When this happens,
this axis is sharded as much as possible (i.e., every dimension becomes
a separate shard).
If the partitioner hits the max_shards
limit, then each shard may end up
larger than max_shard_bytes
. By default max_shards
equals None
and no
limit on the number of shards is enforced.
One reasonable value for max_shard_bytes
is (64 << 20) - 1
, or almost
64MB
, to keep below the protobuf byte limit.
Args:
max_shard_bytes: The maximum size any given shard is allowed to be.
axis: The axis to partition along. Default: outermost axis.
bytes_per_string_element: If the Variable
is of type string, this provides
an estimate of how large each scalar in the Variable
is.
max_shards: The maximum number of shards in int created taking precedence
over max_shard_bytes
.
Returns:
A partition function usable as the partitioner
argument to
variable_scope
, get_variable
, and get_partitioned_variable_list
.
Raises: ValueError: If any of the byte counts are non-positive.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def variable_axis_size_partitioner_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.variable_axis_size_partitioner_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.variable_axis_size_partitioner_layer
Return
Applicative
Origial documentation for Builder.variable_axis_size_partitioner_layer
def variable_axis_size_partitioner_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.variable_axis_size_partitioner, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.variable_axis_size_partitioner
def variable_axis_size_partitioner(max_shard_bytes, axis=0, bytes_per_string_element=16, max_shards=None):
Get a partitioner for VariableScope to keep shards below max_shard_bytes
.
This partitioner will shard a Variable along one axis, attempting to keep
the maximum shard size below max_shard_bytes
. In practice, this is not
always possible when sharding along only one axis. When this happens,
this axis is sharded as much as possible (i.e., every dimension becomes
a separate shard).
If the partitioner hits the max_shards
limit, then each shard may end up
larger than max_shard_bytes
. By default max_shards
equals None
and no
limit on the number of shards is enforced.
One reasonable value for max_shard_bytes
is (64 << 20) - 1
, or almost
64MB
, to keep below the protobuf byte limit.
Args:
max_shard_bytes: The maximum size any given shard is allowed to be.
axis: The axis to partition along. Default: outermost axis.
bytes_per_string_element: If the Variable
is of type string, this provides
an estimate of how large each scalar in the Variable
is.
max_shards: The maximum number of shards in int created taking precedence
over max_shard_bytes
.
Returns:
A partition function usable as the partitioner
argument to
variable_scope
, get_variable
, and get_partitioned_variable_list
.
Raises: ValueError: If any of the byte counts are non-positive.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def variable_op_scope(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.variable_op_scope, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.variable_op_scope
Return
Applicative
Origial documentation for Builder.variable_op_scope
def variable_op_scope(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.variable_op_scope
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.variable_op_scope
def variable_op_scope()
Deprecated: context manager for defining an op that creates variables.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def variable_op_scope_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.variable_op_scope_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.variable_op_scope_layer
Return
Applicative
Origial documentation for Builder.variable_op_scope_layer
def variable_op_scope_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.variable_op_scope, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.variable_op_scope
def variable_op_scope():
Deprecated: context manager for defining an op that creates variables.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def verify_tensor_all_finite(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.verify_tensor_all_finite, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.verify_tensor_all_finite
Return
Applicative
Origial documentation for Builder.verify_tensor_all_finite
def verify_tensor_all_finite(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.verify_tensor_all_finite
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.verify_tensor_all_finite
def verify_tensor_all_finite(t, msg, name=None)
Assert that the tensor does not contain any NaN's or Inf's.
Args: t: Tensor to check. msg: Message to log on failure. name: A name for this operation (optional).
Returns:
Same tensor as t
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def verify_tensor_all_finite_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.verify_tensor_all_finite_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.verify_tensor_all_finite_layer
Return
Applicative
Origial documentation for Builder.verify_tensor_all_finite_layer
def verify_tensor_all_finite_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.verify_tensor_all_finite, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.verify_tensor_all_finite
def verify_tensor_all_finite(t, msg, name=None):
Assert that the tensor does not contain any NaN's or Inf's.
Args: t: Tensor to check. msg: Message to log on failure. name: A name for this operation (optional).
Returns:
Same tensor as t
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def weighted_cross_entropy_with_logits(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.weighted_cross_entropy_with_logits, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.weighted_cross_entropy_with_logits
Return
Applicative
Origial documentation for Builder.weighted_cross_entropy_with_logits
def weighted_cross_entropy_with_logits(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.weighted_cross_entropy_with_logits
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.weighted_cross_entropy_with_logits
def weighted_cross_entropy_with_logits(logits, targets, pos_weight, name=None)
Computes a weighted cross entropy.
This is like sigmoid_cross_entropy_with_logits()
except that pos_weight
,
allows one to trade off recall and precision by up- or down-weighting the
cost of a positive error relative to a negative error.
The usual cross-entropy cost is defined as:
targets * -log(sigmoid(logits)) + (1 - targets) * -log(1 - sigmoid(logits))
The argument pos_weight
is used as a multiplier for the positive targets:
targets * -log(sigmoid(logits)) * pos_weight + (1 - targets) * -log(1 - sigmoid(logits))
For brevity, let x = logits
, z = targets
, q = pos_weight
.
The loss is:
qz * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x)) = qz * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x))) = qz * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x))) = qz * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x)) = (1 - z) * x + (qz + 1 - z) * log(1 + exp(-x)) = (1 - z) * x + (1 + (q - 1) * z) * log(1 + exp(-x))
Setting l = (1 + (q - 1) * z)
, to ensure stability and avoid overflow,
the implementation uses
(1 - z) * x + l * (log(1 + exp(-abs(x))) + max(-x, 0))
logits
and targets
must have the same type and shape.
Args:
logits: A Tensor
of type float32
or float64
.
targets: A Tensor
of the same type and shape as logits
.
pos_weight: A coefficient to use on the positive examples.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as logits
with the componentwise
weightedlogistic losses.
Raises:
ValueError: If logits
and targets
do not have the same shape.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def weighted_cross_entropy_with_logits_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.weighted_cross_entropy_with_logits_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.weighted_cross_entropy_with_logits_layer
Return
Applicative
Origial documentation for Builder.weighted_cross_entropy_with_logits_layer
def weighted_cross_entropy_with_logits_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.weighted_cross_entropy_with_logits, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.weighted_cross_entropy_with_logits
def weighted_cross_entropy_with_logits(logits, targets, pos_weight, name=None):
Computes a weighted cross entropy.
This is like sigmoid_cross_entropy_with_logits()
except that pos_weight
,
allows one to trade off recall and precision by up- or down-weighting the
cost of a positive error relative to a negative error.
The usual cross-entropy cost is defined as:
targets * -log(sigmoid(logits)) + (1 - targets) * -log(1 - sigmoid(logits))
The argument pos_weight
is used as a multiplier for the positive targets:
targets * -log(sigmoid(logits)) * pos_weight + (1 - targets) * -log(1 - sigmoid(logits))
For brevity, let x = logits
, z = targets
, q = pos_weight
.
The loss is:
qz * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x)) = qz * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x))) = qz * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x))) = qz * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x)) = (1 - z) * x + (qz + 1 - z) * log(1 + exp(-x)) = (1 - z) * x + (1 + (q - 1) * z) * log(1 + exp(-x))
Setting l = (1 + (q - 1) * z)
, to ensure stability and avoid overflow,
the implementation uses
(1 - z) * x + l * (log(1 + exp(-abs(x))) + max(-x, 0))
logits
and targets
must have the same type and shape.
Args:
logits: A Tensor
of type float32
or float64
.
targets: A Tensor
of the same type and shape as logits
.
pos_weight: A coefficient to use on the positive examples.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as logits
with the componentwise
weightedlogistic losses.
Raises:
ValueError: If logits
and targets
do not have the same shape.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def where(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.where, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.where
Return
Applicative
Origial documentation for Builder.where
def where(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.where
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.where
def where(input, name=None)
Returns locations of true values in a boolean tensor.
This operation returns the coordinates of true elements in input
. The
coordinates are returned in a 2-D tensor where the first dimension (rows)
represents the number of true elements, and the second dimension (columns)
represents the coordinates of the true elements. Keep in mind, the shape of
the output tensor can vary depending on how many true values there are in
input
. Indices are output in row-major order.
For example:
```prettyprint
'input' tensor is [[True, False]
[True, False]]
'input' has two true values, so output has two coordinates.
'input' has rank of 2, so coordinates have two indices.
where(input) ==> [[0, 0], [1, 0]]
input
tensor is [[[True, False]
[True, False]]
[[False, True]
[False, True]]
[[False, False]
[False, True]]]
'input' has 5 true values, so output has 5 coordinates.
'input' has rank of 3, so coordinates have three indices.
where(input) ==> [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1], [2, 1, 1]] ```
Args:
input: A Tensor
of type bool
.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def where_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.where_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.where_layer
Return
Applicative
Origial documentation for Builder.where_layer
def where_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.where, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.where
def where(input, name=None):
Returns locations of true values in a boolean tensor.
This operation returns the coordinates of true elements in input
. The
coordinates are returned in a 2-D tensor where the first dimension (rows)
represents the number of true elements, and the second dimension (columns)
represents the coordinates of the true elements. Keep in mind, the shape of
the output tensor can vary depending on how many true values there are in
input
. Indices are output in row-major order.
For example:
```prettyprint
'input' tensor is [[True, False]
[True, False]]
'input' has two true values, so output has two coordinates.
'input' has rank of 2, so coordinates have two indices.
where(input) ==> [[0, 0], [1, 0]]
input
tensor is [[[True, False]
[True, False]]
[[False, True]
[False, True]]
[[False, False]
[False, True]]]
'input' has 5 true values, so output has 5 coordinates.
'input' has rank of 3, so coordinates have three indices.
where(input) ==> [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1], [2, 1, 1]] ```
Args:
input: A Tensor
of type bool
.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def while_loop(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.while_loop, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.while_loop
Return
Applicative
Origial documentation for Builder.while_loop
def while_loop(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.while_loop
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.while_loop
def while_loop(cond, body, loop_vars, shape_invariants=None, parallel_iterations=10, back_prop=True, swap_memory=False, name=None)
Repeat body
while the condition cond
is true.
cond
is a callable returning a boolean scalar tensor. body
is a callable
returning a (possibly nested) tuple or list of tensors of the same
arity (length and structure) and types as loop_vars
. loop_vars
is a
(possibly nested) tuple or list of tensors that is passed to both cond
and body
. cond
and body
both take as many arguments as there are
loop_vars
.
While cond
evaluates to true, body
is executed.
In addition to regular Tensors or IndexedSlices, the body may accept and return TensorArray objects. The flows of the TensorArray objects will be appropriately forwarded between loops and during gradient calculations.
For correctness, tf.while_loop()
strictly enforces shape invariants for
the loop variables. A shape invariant is a (possibly partial) shape that
is unchanged across the iterations of the loop. An error will be raised
if the shape of a loop variable after an iteration is determined to be more
general than or incompatible with its shape invariant. For example, a shape
of [11, None] is more general than a shape of [11, 17], and [11, 21] is not
compatible with [11, 17]. By default (if the argument shape_invariants
is
not specified), it is assumed that the initial shape of each tensor in
loop_vars
is the same in every iteration. The shape_invariants
argument
allows the caller to specify a less specific shape invariant for each loop
variable, which is needed if the shape varies between iterations. The
Tensor.set_shape()
function may also be used in the body
function to indicate that
the output loop variable has a particular shape. The shape invariant for
SparseTensor and IndexedSlices are treated specially as follows:
a) If a loop variable is a SparseTensor, the shape invariant must be TensorShape([r]) where r is the rank of the dense tensor represented by the sparse tensor. It means the shapes of the three tensors of the SparseTensor are ([None], [None, r], [r]). NOTE: The shape invariant here is the shape of the SparseTensor.shape property. It must be the shape of a vector.
b) If a loop variable is an IndexedSlices, the shape invariant must be a shape invariant of the values tensor of the IndexedSlices. It means the shapes of the three tensors of the IndexedSlices are (shape, [shape[0]], [shape.ndims]).
while_loop
implements non-strict semantics, enabling multiple iterations
to run in parallel. The maximum number of parallel iterations can be
controlled by parallel_iterations
, which gives users some control over
memory consumption and execution order. For correct programs, while_loop
should return the same result for any parallel_iterations > 0.
For training, TensorFlow remembers the tensors that are produced in the forward inference but needed in back propagation. These tensors can be a main source of memory consumption and often cause OOM problems when training on GPUs. When the flag swap_memory is true, we swap out these tensors from GPU to CPU. This for example allows us to train RNN models with very long sequences and large batches.
Args:
cond: A callable that represents the termination condition of the loop.
body: A callable that represents the loop body.
loop_vars: A (possibly nested) tuple or list of numpy array, Tensor
,
and TensorArray
objects.
shape_invariants: The shape invariants for the loop variables.
parallel_iterations: The number of iterations allowed to run in parallel.
back_prop: Whether backprop is enabled for this while loop.
swap_memory: Whether GPU-CPU memory swap is enabled for this loop.
name: Optional name prefix for the returned tensors.
Returns:
The output tensors for the loop variables after the loop. When the length
of loop_vars
is 1 this is a Tensor, TensorArray or IndexedSlice and when
the length of loop_vars
is greater than 1 it returns a list.
Raises:
TypeError: if cond
or body
is not callable.
ValueError: if loop_vars
is empty.
Example:
python
i = tf.constant(0)
c = lambda i: tf.less(i, 10)
b = lambda i: tf.add(i, 1)
r = tf.while_loop(c, b, [i])
Example with nesting:
python
ijk_0 = (tf.constant(0), (tf.constant(1), tf.constant(2)))
c = lambda i, (j, k): i < 10
b = lambda i, (j, k): (i + 1, ((j + k), (j - k)))
ijk_final = tf.while_loop(c, b, ijk_0)
Example using shape_invariants:
python
i0 = tf.constant(0)
m0 = tf.ones([2, 2])
c = lambda i, m: i < 10
b = lambda i, m: [i+1, tf.concat(0, [m, m])]
tf.while_loop(
c, b, loop_vars=[i0, m0],
shape_invariants=[i0.get_shape(), tensor_shape.TensorShape([None, 2])])
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def while_loop_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.while_loop_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.while_loop_layer
Return
Applicative
Origial documentation for Builder.while_loop_layer
def while_loop_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.while_loop, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.while_loop
def while_loop(cond, body, loop_vars, shape_invariants=None, parallel_iterations=10, back_prop=True, swap_memory=False, name=None):
Repeat body
while the condition cond
is true.
cond
is a callable returning a boolean scalar tensor. body
is a callable
returning a (possibly nested) tuple or list of tensors of the same
arity (length and structure) and types as loop_vars
. loop_vars
is a
(possibly nested) tuple or list of tensors that is passed to both cond
and body
. cond
and body
both take as many arguments as there are
loop_vars
.
While cond
evaluates to true, body
is executed.
In addition to regular Tensors or IndexedSlices, the body may accept and return TensorArray objects. The flows of the TensorArray objects will be appropriately forwarded between loops and during gradient calculations.
For correctness, tf.while_loop()
strictly enforces shape invariants for
the loop variables. A shape invariant is a (possibly partial) shape that
is unchanged across the iterations of the loop. An error will be raised
if the shape of a loop variable after an iteration is determined to be more
general than or incompatible with its shape invariant. For example, a shape
of [11, None] is more general than a shape of [11, 17], and [11, 21] is not
compatible with [11, 17]. By default (if the argument shape_invariants
is
not specified), it is assumed that the initial shape of each tensor in
loop_vars
is the same in every iteration. The shape_invariants
argument
allows the caller to specify a less specific shape invariant for each loop
variable, which is needed if the shape varies between iterations. The
Tensor.set_shape()
function may also be used in the body
function to indicate that
the output loop variable has a particular shape. The shape invariant for
SparseTensor and IndexedSlices are treated specially as follows:
a) If a loop variable is a SparseTensor, the shape invariant must be TensorShape([r]) where r is the rank of the dense tensor represented by the sparse tensor. It means the shapes of the three tensors of the SparseTensor are ([None], [None, r], [r]). NOTE: The shape invariant here is the shape of the SparseTensor.shape property. It must be the shape of a vector.
b) If a loop variable is an IndexedSlices, the shape invariant must be a shape invariant of the values tensor of the IndexedSlices. It means the shapes of the three tensors of the IndexedSlices are (shape, [shape[0]], [shape.ndims]).
while_loop
implements non-strict semantics, enabling multiple iterations
to run in parallel. The maximum number of parallel iterations can be
controlled by parallel_iterations
, which gives users some control over
memory consumption and execution order. For correct programs, while_loop
should return the same result for any parallel_iterations > 0.
For training, TensorFlow remembers the tensors that are produced in the forward inference but needed in back propagation. These tensors can be a main source of memory consumption and often cause OOM problems when training on GPUs. When the flag swap_memory is true, we swap out these tensors from GPU to CPU. This for example allows us to train RNN models with very long sequences and large batches.
Args:
cond: A callable that represents the termination condition of the loop.
body: A callable that represents the loop body.
loop_vars: A (possibly nested) tuple or list of numpy array, Tensor
,
and TensorArray
objects.
shape_invariants: The shape invariants for the loop variables.
parallel_iterations: The number of iterations allowed to run in parallel.
back_prop: Whether backprop is enabled for this while loop.
swap_memory: Whether GPU-CPU memory swap is enabled for this loop.
name: Optional name prefix for the returned tensors.
Returns:
The output tensors for the loop variables after the loop. When the length
of loop_vars
is 1 this is a Tensor, TensorArray or IndexedSlice and when
the length of loop_vars
is greater than 1 it returns a list.
Raises:
TypeError: if cond
or body
is not callable.
ValueError: if loop_vars
is empty.
Example:
python
i = tf.constant(0)
c = lambda i: tf.less(i, 10)
b = lambda i: tf.add(i, 1)
r = tf.while_loop(c, b, [i])
Example with nesting:
python
ijk_0 = (tf.constant(0), (tf.constant(1), tf.constant(2)))
c = lambda i, (j, k): i < 10
b = lambda i, (j, k): (i + 1, ((j + k), (j - k)))
ijk_final = tf.while_loop(c, b, ijk_0)
Example using shape_invariants:
python
i0 = tf.constant(0)
m0 = tf.ones([2, 2])
c = lambda i, m: i < 10
b = lambda i, m: [i+1, tf.concat(0, [m, m])]
tf.while_loop(
c, b, loop_vars=[i0, m0],
shape_invariants=[i0.get_shape(), tensor_shape.TensorShape([None, 2])])
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def xw_plus_b(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.xw_plus_b, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.xw_plus_b
Return
Applicative
Origial documentation for Builder.xw_plus_b
def xw_plus_b(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.xw_plus_b
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.xw_plus_b
def xw_plus_b(x, weights, biases, name=None)
Computes matmul(x, weights) + biases.
Args: x: a 2D tensor. Dimensions typically: batch, in_units weights: a 2D tensor. Dimensions typically: in_units, out_units biases: a 1D tensor. Dimensions: out_units name: A name for the operation (optional). If not specified "xw_plus_b" is used.
Returns: A 2-D Tensor computing matmul(x, weights) + biases. Dimensions typically: batch, out_units.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def xw_plus_b_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.xw_plus_b_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.xw_plus_b_layer
Return
Applicative
Origial documentation for Builder.xw_plus_b_layer
def xw_plus_b_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.xw_plus_b, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.xw_plus_b
def xw_plus_b(x, weights, biases, name=None):
Computes matmul(x, weights) + biases.
Args: x: a 2D tensor. Dimensions typically: batch, in_units weights: a 2D tensor. Dimensions typically: in_units, out_units biases: a 1D tensor. Dimensions: out_units name: A name for the operation (optional). If not specified "xw_plus_b" is used.
Returns: A 2-D Tensor computing matmul(x, weights) + biases. Dimensions typically: batch, out_units.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def xw_plus_b_v1(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.xw_plus_b_v1, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.xw_plus_b_v1
Return
Applicative
Origial documentation for Builder.xw_plus_b_v1
def xw_plus_b_v1(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.xw_plus_b_v1
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.xw_plus_b_v1
def xw_plus_b_v1(x, weights, biases, name=None)
Computes matmul(x, weights) + biases.
This is a deprecated version of that will soon be removed.
Args: x: a 2D tensor. Dimensions typically: batch, in_units weights: a 2D tensor. Dimensions typically: in_units, out_units biases: a 1D tensor. Dimensions: out_units name: A name for the operation (optional). If not specified "xw_plus_b_v1" is used.
Returns: A 2-D Tensor computing matmul(x, weights) + biases. Dimensions typically: batch, out_units.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def xw_plus_b_v1_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.xw_plus_b_v1_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.xw_plus_b_v1_layer
Return
Applicative
Origial documentation for Builder.xw_plus_b_v1_layer
def xw_plus_b_v1_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.xw_plus_b_v1, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.xw_plus_b_v1
def xw_plus_b_v1(x, weights, biases, name=None):
Computes matmul(x, weights) + biases.
This is a deprecated version of that will soon be removed.
Args: x: a 2D tensor. Dimensions typically: batch, in_units weights: a 2D tensor. Dimensions typically: in_units, out_units biases: a 1D tensor. Dimensions: out_units name: A name for the operation (optional). If not specified "xw_plus_b_v1" is used.
Returns: A 2-D Tensor computing matmul(x, weights) + biases. Dimensions typically: batch, out_units.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zero_fraction(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zero_fraction, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zero_fraction
Return
Applicative
Origial documentation for Builder.zero_fraction
def zero_fraction(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.zero_fraction
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.nn.zero_fraction
def zero_fraction(value, name=None)
Returns the fraction of zeros in value
.
If value
is empty, the result is nan
.
This is useful in summaries to measure and report sparsity. For example,
z = tf.Relu(...) summ = tf.scalar_summary('sparsity', tf.nn.zero_fraction(z))
Args: value: A tensor of numeric type. name: A name for the operation (optional).
Returns:
The fraction of zeros in value
, with type float32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zero_fraction_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zero_fraction_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zero_fraction_layer
Return
Applicative
Origial documentation for Builder.zero_fraction_layer
def zero_fraction_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.zero_fraction, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.nn.zero_fraction
def zero_fraction(value, name=None):
Returns the fraction of zeros in value
.
If value
is empty, the result is nan
.
This is useful in summaries to measure and report sparsity. For example,
z = tf.Relu(...) summ = tf.scalar_summary('sparsity', tf.nn.zero_fraction(z))
Args: value: A tensor of numeric type. name: A name for the operation (optional).
Returns:
The fraction of zeros in value
, with type float32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros
Return
Applicative
Origial documentation for Builder.zeros
def zeros(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.zeros
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.zeros
def zeros(shape, dtype=<dtype: 'float32'>, name=None)
Creates a tensor with all elements set to zero.
This operation returns a tensor of type dtype
with shape shape
and
all elements set to zero.
For example:
python
tf.zeros([3, 4], tf.int32) ==> [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Args:
shape: Either a list of integers, or a 1-D Tensor
of type int32
.
dtype: The type of an element in the resulting Tensor
.
name: A name for the operation (optional).
Returns:
A Tensor
with all elements set to zero.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros_initializer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros_initializer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros_initializer
Return
Applicative
Origial documentation for Builder.zeros_initializer
def zeros_initializer(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.zeros_initializer
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.zeros_initializer
def zeros_initializer(shape, dtype=<dtype: 'float32'>, partition_info=None)
An adaptor for zeros() to match the Initializer spec.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros_initializer_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros_initializer_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros_initializer_layer
Return
Applicative
Origial documentation for Builder.zeros_initializer_layer
def zeros_initializer_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.zeros_initializer, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.zeros_initializer
def zeros_initializer(shape, dtype=<dtype: 'float32'>, partition_info=None):
An adaptor for zeros() to match the Initializer spec.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros_layer
Return
Applicative
Origial documentation for Builder.zeros_layer
def zeros_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.zeros, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.zeros
def zeros(shape, dtype=<dtype: 'float32'>, name=None):
Creates a tensor with all elements set to zero.
This operation returns a tensor of type dtype
with shape shape
and
all elements set to zero.
For example:
python
tf.zeros([3, 4], tf.int32) ==> [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Args:
shape: Either a list of integers, or a 1-D Tensor
of type int32
.
dtype: The type of an element in the resulting Tensor
.
name: A name for the operation (optional).
Returns:
A Tensor
with all elements set to zero.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros_like(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros_like, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros_like
Return
Applicative
Origial documentation for Builder.zeros_like
def zeros_like(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.zeros_like
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.zeros_like
def zeros_like(tensor, dtype=None, name=None, optimize=True)
Creates a tensor with all elements set to zero.
Given a single tensor (tensor
), this operation returns a tensor of the
same type and shape as tensor
with all elements set to zero. Optionally,
you can use dtype
to specify a new type for the returned tensor.
For example:
```python
'tensor' is [[1, 2, 3], [4, 5, 6]]
tf.zeros_like(tensor) ==> [[0, 0, 0], [0, 0, 0]] ```
Args:
tensor: A Tensor
.
dtype: A type for the returned Tensor
. Must be float32
, float64
,
int8
, int16
, int32
, int64
, uint8
, complex64
, or complex128
.
name: A name for the operation (optional).
optimize: if true, attempt to statically determine the shape of 'tensor'
and encode it as a constant.
Returns:
A Tensor
with all elements set to zero.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeros_like_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeros_like_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeros_like_layer
Return
Applicative
Origial documentation for Builder.zeros_like_layer
def zeros_like_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.zeros_like, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.zeros_like
def zeros_like(tensor, dtype=None, name=None, optimize=True):
Creates a tensor with all elements set to zero.
Given a single tensor (tensor
), this operation returns a tensor of the
same type and shape as tensor
with all elements set to zero. Optionally,
you can use dtype
to specify a new type for the returned tensor.
For example:
```python
'tensor' is [[1, 2, 3], [4, 5, 6]]
tf.zeros_like(tensor) ==> [[0, 0, 0], [0, 0, 0]] ```
Args:
tensor: A Tensor
.
dtype: A type for the returned Tensor
. Must be float32
, float64
,
int8
, int16
, int32
, int64
, uint8
, complex64
, or complex128
.
name: A name for the operation (optional).
optimize: if true, attempt to statically determine the shape of 'tensor'
and encode it as a constant.
Returns:
A Tensor
with all elements set to zero.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeta(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeta, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeta
Return
Applicative
Origial documentation for Builder.zeta
def zeta(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.zeta
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.zeta
def zeta(x, q, name=None)
Compute the Hurwitz zeta function \(\zeta(x, q)\).
The Hurwitz zeta function is defined as:
\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}
Args:
x: A Tensor
. Must be one of the following types: float32
, float64
.
q: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def zeta_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.zeta_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.zeta_layer
Return
Applicative
Origial documentation for Builder.zeta_layer
def zeta_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.zeta, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.zeta
def zeta(x, q, name=None):
Compute the Hurwitz zeta function \(\zeta(x, q)\).
The Hurwitz zeta function is defined as:
\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}
Args:
x: A Tensor
. Must be one of the following types: float32
, float64
.
q: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)