segment_ids: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor whose rank is equal to the rank of data
's
first dimension. Values should be sorted and can be repeated.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as data
.
Has same shape as data, except for dimension 0 which
has size k
, the number of segments.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def select(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.select, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.select
Return
Applicative
Origial documentation for Builder.select
def select(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.select
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.select
def select(condition, t, e, name=None)
Selects elements from t
or e
, depending on condition
.
The t
, and e
tensors must all have the same shape,
and the output will also have that shape. The condition
tensor
must be a scalar if t
and e
are scalars. If t
and e
are vectors
or higher rank, then condition
must be either a vector with size
matching the first dimension of t
, or must have the same shape as t
.
The condition
tensor acts as a mask that chooses, based on the value at each
element, whether the corresponding element / row in the output should be
taken from t
(if true) or e
(if false).
If condition
is a vector and t
and e
are higher rank matrices, then
it chooses which row (outer dimension) to copy from t
and e
.
If condition
has the same shape as t
and e
, then it chooses which
element to copy from t
and e
.
For example:
```prettyprint
'condition' tensor is [[True, False]
[False, True]]
't' is [[1, 2],
[3, 4]]
'e' is [[5, 6],
[7, 8]]
select(condition, t, e) ==> [[1, 6], [7, 4]]
'condition' tensor is [True, False]
't' is [[1, 2],
[3, 4]]
'e' is [[5, 6],
[7, 8]]
select(condition, t, e) ==> [[1, 2], [7, 8]]
```
Args:
condition: A Tensor
of type bool
.
t: A Tensor
which may have the same shape as condition
.
If condition
is rank 1, t
may have higher rank,
but its first dimension must match the size of condition
.
e: A Tensor
with the same type and shape as t
.
name: A name for the operation (optional).
Returns:
A Tensor
with the same type and shape as t
and e
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def select_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.select_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.select_layer
Return
Applicative
Origial documentation for Builder.select_layer
def select_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.select, ...)
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.select
def select(condition, t, e, name=None):
Selects elements from t
or e
, depending on condition
.
The t
, and e
tensors must all have the same shape,
and the output will also have that shape. The condition
tensor
must be a scalar if t
and e
are scalars. If t
and e
are vectors
or higher rank, then condition
must be either a vector with size
matching the first dimension of t
, or must have the same shape as t
.
The condition
tensor acts as a mask that chooses, based on the value at each
element, whether the corresponding element / row in the output should be
taken from t
(if true) or e
(if false).
If condition
is a vector and t
and e
are higher rank matrices, then
it chooses which row (outer dimension) to copy from t
and e
.
If condition
has the same shape as t
and e
, then it chooses which
element to copy from t
and e
.
For example:
```prettyprint
'condition' tensor is [[True, False]
[False, True]]
't' is [[1, 2],
[3, 4]]
'e' is [[5, 6],
[7, 8]]
select(condition, t, e) ==> [[1, 6], [7, 4]]
'condition' tensor is [True, False]
't' is [[1, 2],
[3, 4]]
'e' is [[5, 6],
[7, 8]]
select(condition, t, e) ==> [[1, 2], [7, 8]]
```
Args:
condition: A Tensor
of type bool
.
t: A Tensor
which may have the same shape as condition
.
If condition
is rank 1, t
may have higher rank,
but its first dimension must match the size of condition
.
e: A Tensor
with the same type and shape as t
.
name: A name for the operation (optional).
Returns:
A Tensor
with the same type and shape as t
and e
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def self_adjoint_eig(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.self_adjoint_eig, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.self_adjoint_eig
Return
Applicative
Origial documentation for Builder.self_adjoint_eig
def self_adjoint_eig(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.self_adjoint_eig
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.self_adjoint_eig
def self_adjoint_eig(tensor, name=None)
Computes the eigen decomposition of a batch of self-adjoint matrices.
Computes the eigenvalues and eigenvectors of the innermost N-by-N matrices
in tensor
such that
tensor[...,:,:] * v[..., :,i] = e[..., i] * v[...,:,i]
, for i=0...N-1.
Args:
tensor: Tensor
of shape [..., N, N]
. Only the lower triangular part of
each inner inner matrix is referenced.
name: string, optional name of the operation.
Returns:
e: Eigenvalues. Shape is [..., N]
.
v: Eigenvectors. Shape is [..., N, N]
. The columns of the inner most
matrices contain eigenvectors of the corresponding matrices in tensor
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def self_adjoint_eig_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.self_adjoint_eig_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.self_adjoint_eig_layer
Return
Applicative
Origial documentation for Builder.self_adjoint_eig_layer
def self_adjoint_eig_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.self_adjoint_eig, ...)
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.self_adjoint_eig
def self_adjoint_eig(tensor, name=None):
Computes the eigen decomposition of a batch of self-adjoint matrices.
Computes the eigenvalues and eigenvectors of the innermost N-by-N matrices
in tensor
such that
tensor[...,:,:] * v[..., :,i] = e[..., i] * v[...,:,i]
, for i=0...N-1.
Args:
tensor: Tensor
of shape [..., N, N]
. Only the lower triangular part of
each inner inner matrix is referenced.
name: string, optional name of the operation.
Returns:
e: Eigenvalues. Shape is [..., N]
.
v: Eigenvectors. Shape is [..., N, N]
. The columns of the inner most
matrices contain eigenvectors of the corresponding matrices in tensor
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def self_adjoint_eigvals(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.self_adjoint_eigvals, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.self_adjoint_eigvals
Return
Applicative
Origial documentation for Builder.self_adjoint_eigvals
def self_adjoint_eigvals(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.self_adjoint_eigvals
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.self_adjoint_eigvals
def self_adjoint_eigvals(tensor, name=None)
Computes the eigenvalues of one or more self-adjoint matrices.
Args:
tensor: Tensor
of shape [..., N, N]
.
name: string, optional name of the operation.
Returns:
e: Eigenvalues. Shape is [..., N]
. The vector e[..., :]
contains the N
eigenvalues of tensor[..., :, :]
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def self_adjoint_eigvals_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.self_adjoint_eigvals_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.self_adjoint_eigvals_layer
Return
Applicative
Origial documentation for Builder.self_adjoint_eigvals_layer
def self_adjoint_eigvals_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.self_adjoint_eigvals, ...)
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.self_adjoint_eigvals
def self_adjoint_eigvals(tensor, name=None):
Computes the eigenvalues of one or more self-adjoint matrices.
Args:
tensor: Tensor
of shape [..., N, N]
.
name: string, optional name of the operation.
Returns:
e: Eigenvalues. Shape is [..., N]
. The vector e[..., :]
contains the N
eigenvalues of tensor[..., :, :]
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def separable_conv2d(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.separable_conv2d, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.separable_conv2d
Return
Applicative
Origial documentation for Builder.separable_conv2d
def separable_conv2d(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.separable_conv2d
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.separable_conv2d
def separable_conv2d(input, depthwise_filter, pointwise_filter, strides, padding, name=None)
2-D convolution with separable filters.
Performs a depthwise convolution that acts separately on channels followed by
a pointwise convolution that mixes channels. Note that this is separability
between dimensions [1, 2]
and 3
, not spatial separability between
dimensions 1
and 2
.
In detail,
output[b, i, j, k] = sum_{di, dj, q, r] input[b, strides[1] * i + di, strides[2] * j + dj, q] * depthwise_filter[di, dj, q, r] * pointwise_filter[0, 0, q * channel_multiplier + r, k]
strides
controls the strides for the depthwise convolution only, since
the pointwise convolution has implicit strides of [1, 1, 1, 1]
. Must have
strides[0] = strides[3] = 1
. For the most common case of the same
horizontal and vertical strides, strides = [1, stride, stride, 1]
.
Args:
input: 4-D Tensor
with shape [batch, in_height, in_width, in_channels]
.
depthwise_filter: 4-D Tensor
with shape
[filter_height, filter_width, in_channels, channel_multiplier]
.
Contains in_channels
convolutional filters of depth 1.
pointwise_filter: 4-D Tensor
with shape
[1, 1, channel_multiplier * in_channels, out_channels]
. Pointwise
filter to mix channels after depthwise_filter
has convolved spatially.
strides: 1-D of size 4. The strides for the depthwise convolution for
each dimension of input
.
padding: A string, either 'VALID'
or 'SAME'
. The padding algorithm.
See the comment
here
name: A name for this operation (optional).
Returns:
A 4-D Tensor
of shape [batch, out_height, out_width, out_channels]
.
Raises: ValueError: If channel_multiplier * in_channels > out_channels, which means that the separable convolution is overparameterized.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def separable_conv2d_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.separable_conv2d_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.separable_conv2d_layer
Return
Applicative
Origial documentation for Builder.separable_conv2d_layer
def separable_conv2d_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.separable_conv2d, ...)
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.separable_conv2d
def separable_conv2d(input, depthwise_filter, pointwise_filter, strides, padding, name=None):
2-D convolution with separable filters.
Performs a depthwise convolution that acts separately on channels followed by
a pointwise convolution that mixes channels. Note that this is separability
between dimensions [1, 2]
and 3
, not spatial separability between
dimensions 1
and 2
.
In detail,
output[b, i, j, k] = sum_{di, dj, q, r] input[b, strides[1] * i + di, strides[2] * j + dj, q] * depthwise_filter[di, dj, q, r] * pointwise_filter[0, 0, q * channel_multiplier + r, k]
strides
controls the strides for the depthwise convolution only, since
the pointwise convolution has implicit strides of [1, 1, 1, 1]
. Must have
strides[0] = strides[3] = 1
. For the most common case of the same
horizontal and vertical strides, strides = [1, stride, stride, 1]
.
Args:
input: 4-D Tensor
with shape [batch, in_height, in_width, in_channels]
.
depthwise_filter: 4-D Tensor
with shape
[filter_height, filter_width, in_channels, channel_multiplier]
.
Contains in_channels
convolutional filters of depth 1.
pointwise_filter: 4-D Tensor
with shape
[1, 1, channel_multiplier * in_channels, out_channels]
. Pointwise
filter to mix channels after depthwise_filter
has convolved spatially.
strides: 1-D of size 4. The strides for the depthwise convolution for
each dimension of input
.
padding: A string, either 'VALID'
or 'SAME'
. The padding algorithm.
See the comment
here
name: A name for this operation (optional).
Returns:
A 4-D Tensor
of shape [batch, out_height, out_width, out_channels]
.
Raises: ValueError: If channel_multiplier * in_channels > out_channels, which means that the separable convolution is overparameterized.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sequence_mask(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sequence_mask, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sequence_mask
Return
Applicative
Origial documentation for Builder.sequence_mask
def sequence_mask(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sequence_mask
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.sequence_mask
def sequence_mask(lengths, maxlen=None, dtype=<dtype: 'bool'>, name=None)
Return a mask tensor representing the first N positions of each row.
Example:
python
tf.sequence_mask([1, 3, 2], 5) =
[[True, False, False, False, False],
[True, True, True, False, False],
[True, True, False, False, False]]
Args: lengths: 1D integer tensor, all its values < maxlen. maxlen: scalar integer tensor, maximum length of each row. Default: use maximum over lengths. dtype: output type of the resulting tensor. name: name of the op. Returns: A 2D mask tensor, as shown in the example above, cast to specified dtype.
Raises: ValueError: if the arguments have invalid rank.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sequence_mask_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sequence_mask_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sequence_mask_layer
Return
Applicative
Origial documentation for Builder.sequence_mask_layer
def sequence_mask_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sequence_mask, ...)
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.sequence_mask
def sequence_mask(lengths, maxlen=None, dtype=<dtype: 'bool'>, name=None):
Return a mask tensor representing the first N positions of each row.
Example:
python
tf.sequence_mask([1, 3, 2], 5) =
[[True, False, False, False, False],
[True, True, True, False, False],
[True, True, False, False, False]]
Args: lengths: 1D integer tensor, all its values < maxlen. maxlen: scalar integer tensor, maximum length of each row. Default: use maximum over lengths. dtype: output type of the resulting tensor. name: name of the op. Returns: A 2D mask tensor, as shown in the example above, cast to specified dtype.
Raises: ValueError: if the arguments have invalid rank.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def serialize_many_sparse(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.serialize_many_sparse, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.serialize_many_sparse
Return
Applicative
Origial documentation for Builder.serialize_many_sparse
def serialize_many_sparse(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.serialize_many_sparse
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.serialize_many_sparse
def serialize_many_sparse(sp_input, name=None)
Serialize an N
-minibatch SparseTensor
into an [N, 3]
string Tensor
.
The SparseTensor
must have rank R
greater than 1, and the first dimension
is treated as the minibatch dimension. Elements of the SparseTensor
must be sorted in increasing order of this first dimension. The serialized
SparseTensor
objects going into each row of the output Tensor
will have
rank R-1
.
The minibatch size N
is extracted from sparse_shape[0]
.
Args:
sp_input: The input rank R
SparseTensor
.
name: A name prefix for the returned tensors (optional).
Returns:
A string matrix (2-D Tensor
) with N
rows and 3
columns.
Each column represents serialized SparseTensor
's indices, values, and
shape (respectively).
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def serialize_many_sparse_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.serialize_many_sparse_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.serialize_many_sparse_layer
Return
Applicative
Origial documentation for Builder.serialize_many_sparse_layer
def serialize_many_sparse_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.serialize_many_sparse, ...)
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.serialize_many_sparse
def serialize_many_sparse(sp_input, name=None):
Serialize an N
-minibatch SparseTensor
into an [N, 3]
string Tensor
.
The SparseTensor
must have rank R
greater than 1, and the first dimension
is treated as the minibatch dimension. Elements of the SparseTensor
must be sorted in increasing order of this first dimension. The serialized
SparseTensor
objects going into each row of the output Tensor
will have
rank R-1
.
The minibatch size N
is extracted from sparse_shape[0]
.
Args:
sp_input: The input rank R
SparseTensor
.
name: A name prefix for the returned tensors (optional).
Returns:
A string matrix (2-D Tensor
) with N
rows and 3
columns.
Each column represents serialized SparseTensor
's indices, values, and
shape (respectively).
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def serialize_sparse(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.serialize_sparse, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.serialize_sparse
Return
Applicative
Origial documentation for Builder.serialize_sparse
def serialize_sparse(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.serialize_sparse
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.serialize_sparse
def serialize_sparse(sp_input, name=None)
Serialize a SparseTensor
into a string 3-vector (1-D Tensor
) object.
Args:
sp_input: The input SparseTensor
.
name: A name prefix for the returned tensors (optional).
Returns:
A string 3-vector (1D Tensor
), with each column representing the
serialized SparseTensor
's indices, values, and shape (respectively).
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def serialize_sparse_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.serialize_sparse_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.serialize_sparse_layer
Return
Applicative
Origial documentation for Builder.serialize_sparse_layer
def serialize_sparse_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.serialize_sparse, ...)
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.serialize_sparse
def serialize_sparse(sp_input, name=None):
Serialize a SparseTensor
into a string 3-vector (1-D Tensor
) object.
Args:
sp_input: The input SparseTensor
.
name: A name prefix for the returned tensors (optional).
Returns:
A string 3-vector (1D Tensor
), with each column representing the
serialized SparseTensor
's indices, values, and shape (respectively).
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def set_random_seed(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.set_random_seed, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.set_random_seed
Return
Applicative
Origial documentation for Builder.set_random_seed
def set_random_seed(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.set_random_seed
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.set_random_seed
def set_random_seed(seed)
Sets the graph-level random seed.
Operations that rely on a random seed actually derive it from two seeds: the graph-level and operation-level seeds. This sets the graph-level seed.
Its interactions with operation-level seeds is as follows:
- If neither the graph-level nor the operation seed is set: A random seed is used for this op.
- If the graph-level seed is set, but the operation seed is not: The system deterministically picks an operation seed in conjunction with the graph-level seed so that it gets a unique random sequence.
- If the graph-level seed is not set, but the operation seed is set: A default graph-level seed and the specified operation seed are used to determine the random sequence.
- If both the graph-level and the operation seed are set: Both seeds are used in conjunction to determine the random sequence.
To illustrate the user-visible effects, consider these examples:
To generate different sequences across sessions, set neither graph-level nor op-level seeds:
```python a = tf.random_uniform([1]) b = tf.random_normal([1])
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A3' print(sess2.run(a)) # generates 'A4' print(sess2.run(b)) # generates 'B3' print(sess2.run(b)) # generates 'B4' ```
To generate the same repeatable sequence for an op across sessions, set the seed for the op:
```python a = tf.random_uniform([1], seed=1) b = tf.random_normal([1])
Repeatedly running this block with the same graph will generate the same
sequence of values for 'a', but different sequences of values for 'b'.
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A1' print(sess2.run(a)) # generates 'A2' print(sess2.run(b)) # generates 'B3' print(sess2.run(b)) # generates 'B4' ```
To make the random sequences generated by all ops be repeatable across sessions, set a graph-level seed:
```python tf.set_random_seed(1234) a = tf.random_uniform([1]) b = tf.random_normal([1])
Repeatedly running this block with the same graph will generate different
sequences of 'a' and 'b'.
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A1' print(sess2.run(a)) # generates 'A2' print(sess2.run(b)) # generates 'B1' print(sess2.run(b)) # generates 'B2' ```
Args: seed: integer.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def set_random_seed_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.set_random_seed_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.set_random_seed_layer
Return
Applicative
Origial documentation for Builder.set_random_seed_layer
def set_random_seed_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.set_random_seed, ...)
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.set_random_seed
def set_random_seed(seed):
Sets the graph-level random seed.
Operations that rely on a random seed actually derive it from two seeds: the graph-level and operation-level seeds. This sets the graph-level seed.
Its interactions with operation-level seeds is as follows:
- If neither the graph-level nor the operation seed is set: A random seed is used for this op.
- If the graph-level seed is set, but the operation seed is not: The system deterministically picks an operation seed in conjunction with the graph-level seed so that it gets a unique random sequence.
- If the graph-level seed is not set, but the operation seed is set: A default graph-level seed and the specified operation seed are used to determine the random sequence.
- If both the graph-level and the operation seed are set: Both seeds are used in conjunction to determine the random sequence.
To illustrate the user-visible effects, consider these examples:
To generate different sequences across sessions, set neither graph-level nor op-level seeds:
```python a = tf.random_uniform([1]) b = tf.random_normal([1])
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A3' print(sess2.run(a)) # generates 'A4' print(sess2.run(b)) # generates 'B3' print(sess2.run(b)) # generates 'B4' ```
To generate the same repeatable sequence for an op across sessions, set the seed for the op:
```python a = tf.random_uniform([1], seed=1) b = tf.random_normal([1])
Repeatedly running this block with the same graph will generate the same
sequence of values for 'a', but different sequences of values for 'b'.
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A1' print(sess2.run(a)) # generates 'A2' print(sess2.run(b)) # generates 'B3' print(sess2.run(b)) # generates 'B4' ```
To make the random sequences generated by all ops be repeatable across sessions, set a graph-level seed:
```python tf.set_random_seed(1234) a = tf.random_uniform([1]) b = tf.random_normal([1])
Repeatedly running this block with the same graph will generate different
sequences of 'a' and 'b'.
print("Session 1") with tf.Session() as sess1: print(sess1.run(a)) # generates 'A1' print(sess1.run(a)) # generates 'A2' print(sess1.run(b)) # generates 'B1' print(sess1.run(b)) # generates 'B2'
print("Session 2") with tf.Session() as sess2: print(sess2.run(a)) # generates 'A1' print(sess2.run(a)) # generates 'A2' print(sess2.run(b)) # generates 'B1' print(sess2.run(b)) # generates 'B2' ```
Args: seed: integer.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def shape(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.shape, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.shape
Return
Applicative
Origial documentation for Builder.shape
def shape(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.shape
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.shape
def shape(input, name=None, out_type=<dtype: 'int32'>)
Returns the shape of a tensor.
This operation returns a 1-D integer tensor representing the shape of input
.
For example:
```python
't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]
shape(t) ==> [2, 2, 3] ```
Args:
input: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
out_type: (Optional) The specified output type of the operation
(int32
or int64
). Defaults to tf.int32.
Returns:
A Tensor
of type out_type
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def shape_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.shape_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.shape_layer
Return
Applicative
Origial documentation for Builder.shape_layer
def shape_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.shape, ...)
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.shape
def shape(input, name=None, out_type=<dtype: 'int32'>):
Returns the shape of a tensor.
This operation returns a 1-D integer tensor representing the shape of input
.
For example:
```python
't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]
shape(t) ==> [2, 2, 3] ```
Args:
input: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
out_type: (Optional) The specified output type of the operation
(int32
or int64
). Defaults to tf.int32.
Returns:
A Tensor
of type out_type
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def shape_n(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.shape_n, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.shape_n
Return
Applicative
Origial documentation for Builder.shape_n
def shape_n(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.shape_n
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.shape_n
def shape_n(input, out_type=None, name=None)
Returns shape of tensors.
This operation returns N 1-D integer tensors representing shape of input[i]s
.
Args:
input: A list of at least 1 Tensor
objects of the same type.
out_type: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A list with the same number of Tensor
objects as input
of Tensor
objects of type out_type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def shape_n_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.shape_n_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.shape_n_layer
Return
Applicative
Origial documentation for Builder.shape_n_layer
def shape_n_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.shape_n, ...)
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.shape_n
def shape_n(input, out_type=None, name=None):
Returns shape of tensors.
This operation returns N 1-D integer tensors representing shape of input[i]s
.
Args:
input: A list of at least 1 Tensor
objects of the same type.
out_type: An optional tf.DType
from: tf.int32, tf.int64
. Defaults to tf.int32
.
name: A name for the operation (optional).
Returns:
A list with the same number of Tensor
objects as input
of Tensor
objects of type out_type.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sigmoid(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sigmoid, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sigmoid
Return
Applicative
Origial documentation for Builder.sigmoid
def sigmoid(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sigmoid
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.sigmoid
def sigmoid(x, name=None)
Computes sigmoid of x
element-wise.
Specifically, y = 1 / (1 + exp(-x))
.
Args:
x: A Tensor with type float32
, float64
, int32
, complex64
, int64
,
or qint32
.
name: A name for the operation (optional).
Returns:
A Tensor 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 sigmoid_cross_entropy_with_logits(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sigmoid_cross_entropy_with_logits, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sigmoid_cross_entropy_with_logits
Return
Applicative
Origial documentation for Builder.sigmoid_cross_entropy_with_logits
def sigmoid_cross_entropy_with_logits(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.sigmoid_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.sigmoid_cross_entropy_with_logits
def sigmoid_cross_entropy_with_logits(logits, targets, name=None)
Computes sigmoid cross entropy given logits
.
Measures the probability error in discrete classification tasks in which each class is independent and not mutually exclusive. For instance, one could perform multilabel classification where a picture can contain both an elephant and a dog at the same time.
For brevity, let x = logits
, z = targets
. The logistic loss is
z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x)) = z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x))) = z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x))) = z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x)) = (1 - z) * x + log(1 + exp(-x)) = x - x * z + log(1 + exp(-x))
For x < 0, to avoid overflow in exp(-x), we reformulate the above
x - x * z + log(1 + exp(-x)) = log(exp(x)) - x * z + log(1 + exp(-x)) = - x * z + log(1 + exp(x))
Hence, to ensure stability and avoid overflow, the implementation uses this equivalent formulation
max(x, 0) - x * z + log(1 + exp(-abs(x)))
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
.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as logits
with the componentwise
logistic 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 sigmoid_cross_entropy_with_logits_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sigmoid_cross_entropy_with_logits_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sigmoid_cross_entropy_with_logits_layer
Return
Applicative
Origial documentation for Builder.sigmoid_cross_entropy_with_logits_layer
def sigmoid_cross_entropy_with_logits_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.sigmoid_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.sigmoid_cross_entropy_with_logits
def sigmoid_cross_entropy_with_logits(logits, targets, name=None):
Computes sigmoid cross entropy given logits
.
Measures the probability error in discrete classification tasks in which each class is independent and not mutually exclusive. For instance, one could perform multilabel classification where a picture can contain both an elephant and a dog at the same time.
For brevity, let x = logits
, z = targets
. The logistic loss is
z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x)) = z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x))) = z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x))) = z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x)) = (1 - z) * x + log(1 + exp(-x)) = x - x * z + log(1 + exp(-x))
For x < 0, to avoid overflow in exp(-x), we reformulate the above
x - x * z + log(1 + exp(-x)) = log(exp(x)) - x * z + log(1 + exp(-x)) = - x * z + log(1 + exp(x))
Hence, to ensure stability and avoid overflow, the implementation uses this equivalent formulation
max(x, 0) - x * z + log(1 + exp(-abs(x)))
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
.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as logits
with the componentwise
logistic 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 sigmoid_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sigmoid_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sigmoid_layer
Return
Applicative
Origial documentation for Builder.sigmoid_layer
def sigmoid_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sigmoid, ...)
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.sigmoid
def sigmoid(x, name=None):
Computes sigmoid of x
element-wise.
Specifically, y = 1 / (1 + exp(-x))
.
Args:
x: A Tensor with type float32
, float64
, int32
, complex64
, int64
,
or qint32
.
name: A name for the operation (optional).
Returns:
A Tensor 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 sign(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sign, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sign
Return
Applicative
Origial documentation for Builder.sign
def sign(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sign
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.sign
def sign(x, name=None)
Returns an element-wise indication of the sign of a number.
y = sign(x) = -1
if x < 0
; 0 if x == 0
; 1 if x > 0
.
For complex numbers, y = sign(x) = x / |x|
if x != 0
, otherwise y = 0
.
Args:
x: A Tensor
or SparseTensor
. Must be one of the following types: half
,
float32
, float64
, int32
, int64
, complex64
, complex128
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
, respectively. 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 sign_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sign_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sign_layer
Return
Applicative
Origial documentation for Builder.sign_layer
def sign_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sign, ...)
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.sign
def sign(x, name=None):
Returns an element-wise indication of the sign of a number.
y = sign(x) = -1
if x < 0
; 0 if x == 0
; 1 if x > 0
.
For complex numbers, y = sign(x) = x / |x|
if x != 0
, otherwise y = 0
.
Args:
x: A Tensor
or SparseTensor
. Must be one of the following types: half
,
float32
, float64
, int32
, int64
, complex64
, complex128
.
name: A name for the operation (optional).
Returns:
A Tensor
or SparseTensor
, respectively. 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 sin(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sin, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sin
Return
Applicative
Origial documentation for Builder.sin
def sin(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sin
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.sin
def sin(x, name=None)
Computes sin of x element-wise.
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, 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 sin_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sin_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sin_layer
Return
Applicative
Origial documentation for Builder.sin_layer
def sin_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sin, ...)
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.sin
def sin(x, name=None):
Computes sin of x element-wise.
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, 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 size(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.size, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.size
Return
Applicative
Origial documentation for Builder.size
def size(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.size
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.size
def size(input, name=None, out_type=<dtype: 'int32'>)
Returns the size of a tensor.
This operation returns an integer representing the number of elements in
input
.
For example:
```python
't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]]
size(t) ==> 12 ```
Args:
input: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
out_type: (Optional) The specified output type of the operation
(int32
or int64
). Defaults to tf.int32.
Returns:
A Tensor
of type out_type
. Defaults to tf.int32.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def size_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.size_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.size_layer
Return
Applicative
Origial documentation for Builder.size_layer
def size_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.size, ...)
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.size
def size(input, name=None, out_type=<dtype: 'int32'>):
Returns the size of a tensor.
This operation returns an integer representing the number of elements in
input
.
For example:
```python
't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]]
size(t) ==> 12 ```
Args:
input: A Tensor
or SparseTensor
.
name: A name for the operation (optional).
out_type: (Optional) The specified output type of the operation
(int32
or int64
). Defaults to tf.int32.
Returns:
A Tensor
of type out_type
. Defaults to tf.int32.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def slice(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.slice, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.slice
Return
Applicative
Origial documentation for Builder.slice
def slice(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.slice
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.slice
def slice(input_, begin, size, name=None)
Extracts a slice from a tensor.
This operation extracts a slice of size size
from a tensor input
starting
at the location specified by begin
. The slice size
is represented as a
tensor shape, where size[i]
is the number of elements of the 'i'th dimension
of input
that you want to slice. The starting location (begin
) for the
slice is represented as an offset in each dimension of input
. In other
words, begin[i]
is the offset into the 'i'th dimension of input
that you
want to slice from.
begin
is zero-based; size
is one-based. If size[i]
is -1,
all remaining elements in dimension i are included in the
slice. In other words, this is equivalent to setting:
size[i] = input.dim_size(i) - begin[i]
This operation requires that:
0 <= begin[i] <= begin[i] + size[i] <= Di for i in [0, n]
For example:
```
'input' is [[[1, 1, 1], [2, 2, 2]],
[[3, 3, 3], [4, 4, 4]],
[[5, 5, 5], [6, 6, 6]]]
tf.slice(input, [1, 0, 0], [1, 1, 3]) ==> [[[3, 3, 3]]] tf.slice(input, [1, 0, 0], [1, 2, 3]) ==> [[[3, 3, 3], [4, 4, 4]]] tf.slice(input, [1, 0, 0], [2, 1, 3]) ==> [[[3, 3, 3]], [[5, 5, 5]]] ```
Args:
input_: A Tensor
.
begin: An int32
or int64
Tensor
.
size: An int32
or int64
Tensor
.
name: A name for the operation (optional).
Returns:
A Tensor
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 slice_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.slice_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.slice_layer
Return
Applicative
Origial documentation for Builder.slice_layer
def slice_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.slice, ...)
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.slice
def slice(input_, begin, size, name=None):
Extracts a slice from a tensor.
This operation extracts a slice of size size
from a tensor input
starting
at the location specified by begin
. The slice size
is represented as a
tensor shape, where size[i]
is the number of elements of the 'i'th dimension
of input
that you want to slice. The starting location (begin
) for the
slice is represented as an offset in each dimension of input
. In other
words, begin[i]
is the offset into the 'i'th dimension of input
that you
want to slice from.
begin
is zero-based; size
is one-based. If size[i]
is -1,
all remaining elements in dimension i are included in the
slice. In other words, this is equivalent to setting:
size[i] = input.dim_size(i) - begin[i]
This operation requires that:
0 <= begin[i] <= begin[i] + size[i] <= Di for i in [0, n]
For example:
```
'input' is [[[1, 1, 1], [2, 2, 2]],
[[3, 3, 3], [4, 4, 4]],
[[5, 5, 5], [6, 6, 6]]]
tf.slice(input, [1, 0, 0], [1, 1, 3]) ==> [[[3, 3, 3]]] tf.slice(input, [1, 0, 0], [1, 2, 3]) ==> [[[3, 3, 3], [4, 4, 4]]] tf.slice(input, [1, 0, 0], [2, 1, 3]) ==> [[[3, 3, 3]], [[5, 5, 5]]] ```
Args:
input_: A Tensor
.
begin: An int32
or int64
Tensor
.
size: An int32
or int64
Tensor
.
name: A name for the operation (optional).
Returns:
A Tensor
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 softmax(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softmax, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softmax
Return
Applicative
Origial documentation for Builder.softmax
def softmax(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.softmax
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.softmax
def softmax(logits, dim=-1, name=None)
Computes log softmax activations.
For each batch i
and class j
we have
softmax = exp(logits) / reduce_sum(exp(logits), dim)
Args:
logits: A non-empty Tensor
. Must be one of the following types: half
,
float32
, float64
.
dim: The dimension softmax would be performed on. The default is -1 which
indicates the last dimension.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as logits
. Same shape as logits
.
Raises:
InvalidArgumentError: if logits
is empty or dim
is beyond the last
dimension of logits
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softmax_cross_entropy_with_logits(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softmax_cross_entropy_with_logits, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softmax_cross_entropy_with_logits
Return
Applicative
Origial documentation for Builder.softmax_cross_entropy_with_logits
def softmax_cross_entropy_with_logits(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.softmax_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.softmax_cross_entropy_with_logits
def softmax_cross_entropy_with_logits(logits, labels, dim=-1, name=None)
Computes softmax cross entropy between logits
and labels
.
Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
NOTE: While the classes are mutually exclusive, their probabilities
need not be. All that is required is that each row of labels
is
a valid probability distribution. If they are not, the computation of the
gradient will be incorrect.
If using exclusive labels
(wherein one and only
one class is true at a time), see sparse_softmax_cross_entropy_with_logits
.
WARNING: This op expects unscaled logits, since it performs a softmax
on logits
internally for efficiency. Do not call this op with the
output of softmax
, as it will produce incorrect results.
logits
and labels
must have the same shape [batch_size, num_classes]
and the same dtype (either float16
, float32
, or float64
).
Args:
logits: Unscaled log probabilities.
labels: Each row labels[i]
must be a valid probability distribution.
dim: The class dimension. Defaulted to -1 which is the last dimension.
name: A name for the operation (optional).
Returns:
A 1-D Tensor
of length batch_size
of the same type as logits
with the
softmax cross entropy loss.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softmax_cross_entropy_with_logits_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softmax_cross_entropy_with_logits_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softmax_cross_entropy_with_logits_layer
Return
Applicative
Origial documentation for Builder.softmax_cross_entropy_with_logits_layer
def softmax_cross_entropy_with_logits_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.softmax_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.softmax_cross_entropy_with_logits
def softmax_cross_entropy_with_logits(logits, labels, dim=-1, name=None):
Computes softmax cross entropy between logits
and labels
.
Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
NOTE: While the classes are mutually exclusive, their probabilities
need not be. All that is required is that each row of labels
is
a valid probability distribution. If they are not, the computation of the
gradient will be incorrect.
If using exclusive labels
(wherein one and only
one class is true at a time), see sparse_softmax_cross_entropy_with_logits
.
WARNING: This op expects unscaled logits, since it performs a softmax
on logits
internally for efficiency. Do not call this op with the
output of softmax
, as it will produce incorrect results.
logits
and labels
must have the same shape [batch_size, num_classes]
and the same dtype (either float16
, float32
, or float64
).
Args:
logits: Unscaled log probabilities.
labels: Each row labels[i]
must be a valid probability distribution.
dim: The class dimension. Defaulted to -1 which is the last dimension.
name: A name for the operation (optional).
Returns:
A 1-D Tensor
of length batch_size
of the same type as logits
with the
softmax cross entropy loss.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softmax_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softmax_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softmax_layer
Return
Applicative
Origial documentation for Builder.softmax_layer
def softmax_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.softmax, ...)
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.softmax
def softmax(logits, dim=-1, name=None):
Computes log softmax activations.
For each batch i
and class j
we have
softmax = exp(logits) / reduce_sum(exp(logits), dim)
Args:
logits: A non-empty Tensor
. Must be one of the following types: half
,
float32
, float64
.
dim: The dimension softmax would be performed on. The default is -1 which
indicates the last dimension.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as logits
. Same shape as logits
.
Raises:
InvalidArgumentError: if logits
is empty or dim
is beyond the last
dimension of logits
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softplus(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softplus, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softplus
Return
Applicative
Origial documentation for Builder.softplus
def softplus(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.softplus
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.softplus
def softplus(features, name=None)
Computes softplus: log(exp(features) + 1)
.
Args:
features: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as features
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softplus_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softplus_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softplus_layer
Return
Applicative
Origial documentation for Builder.softplus_layer
def softplus_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.softplus, ...)
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.softplus
def softplus(features, name=None):
Computes softplus: log(exp(features) + 1)
.
Args:
features: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as features
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softsign(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softsign, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softsign
Return
Applicative
Origial documentation for Builder.softsign
def softsign(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.softsign
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.softsign
def softsign(features, name=None)
Computes softsign: features / (abs(features) + 1)
.
Args:
features: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as features
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def softsign_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.softsign_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.softsign_layer
Return
Applicative
Origial documentation for Builder.softsign_layer
def softsign_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.softsign, ...)
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.softsign
def softsign(features, name=None):
Computes softsign: features / (abs(features) + 1)
.
Args:
features: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as features
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def space_to_batch(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_batch, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_batch
Return
Applicative
Origial documentation for Builder.space_to_batch
def space_to_batch(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.space_to_batch
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.space_to_batch
def space_to_batch(input, paddings, block_size, name=None)
SpaceToBatch for 4-D tensors of type T.
This is a legacy version of the more general SpaceToBatchND.
Zero-pads and then rearranges (permutes) blocks of spatial data into batch.
More specifically, this op outputs a copy of the input tensor where values from
the height
and width
dimensions are moved to the batch
dimension. After
the zero-padding, both height
and width
of the input must be divisible by the
block size.
Args:
input: A Tensor
. 4-D with shape [batch, height, width, depth]
.
paddings: A Tensor
. Must be one of the following types: int32
, int64
.
2-D tensor of non-negative integers with shape [2, 2]
. It specifies
the padding of the input with zeros across the spatial dimensions as follows:
paddings = [[pad_top, pad_bottom], [pad_left, pad_right]] The effective spatial dimensions of the zero-padded input tensor will be: height_pad = pad_top + height + pad_bottom width_pad = pad_left + width + pad_right The attr `block_size` must be greater than one. It indicates the block size. * Non-overlapping blocks of size `block_size x block size` in the height and width dimensions are rearranged into the batch dimension at each location. * The batch of the output tensor is `batch * block_size * block_size`. * Both height_pad and width_pad must be divisible by block_size. The shape of the output will be: [batch*block_size*block_size, height_pad/block_size, width_pad/block_size, depth] Some examples: (1) For the following input of shape `[1, 2, 2, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2]], [[3], [4]]]] ``` The output tensor has shape `[4, 1, 1, 1]` and value: ```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ``` (2) For the following input of shape `[1, 2, 2, 3]` and block_size of 2: ```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ``` The output tensor has shape `[4, 1, 1, 3]` and value: ```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ``` (3) For the following input of shape `[1, 4, 4, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[4, 2, 2, 1]` and value: ```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ``` (4) For the following input of shape `[2, 2, 4, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[8, 1, 2, 1]` and value: ```prettyprint x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]], [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]] ``` Among others, this operation is useful for reducing atrous convolution into regular convolution.
block_size: An int
that is >= 2
.
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 space_to_batch_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_batch_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_batch_layer
Return
Applicative
Origial documentation for Builder.space_to_batch_layer
def space_to_batch_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.space_to_batch, ...)
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.space_to_batch
def space_to_batch(input, paddings, block_size, name=None):
SpaceToBatch for 4-D tensors of type T.
This is a legacy version of the more general SpaceToBatchND.
Zero-pads and then rearranges (permutes) blocks of spatial data into batch.
More specifically, this op outputs a copy of the input tensor where values from
the height
and width
dimensions are moved to the batch
dimension. After
the zero-padding, both height
and width
of the input must be divisible by the
block size.
Args:
input: A Tensor
. 4-D with shape [batch, height, width, depth]
.
paddings: A Tensor
. Must be one of the following types: int32
, int64
.
2-D tensor of non-negative integers with shape [2, 2]
. It specifies
the padding of the input with zeros across the spatial dimensions as follows:
paddings = [[pad_top, pad_bottom], [pad_left, pad_right]] The effective spatial dimensions of the zero-padded input tensor will be: height_pad = pad_top + height + pad_bottom width_pad = pad_left + width + pad_right The attr `block_size` must be greater than one. It indicates the block size. * Non-overlapping blocks of size `block_size x block size` in the height and width dimensions are rearranged into the batch dimension at each location. * The batch of the output tensor is `batch * block_size * block_size`. * Both height_pad and width_pad must be divisible by block_size. The shape of the output will be: [batch*block_size*block_size, height_pad/block_size, width_pad/block_size, depth] Some examples: (1) For the following input of shape `[1, 2, 2, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2]], [[3], [4]]]] ``` The output tensor has shape `[4, 1, 1, 1]` and value: ```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ``` (2) For the following input of shape `[1, 2, 2, 3]` and block_size of 2: ```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ``` The output tensor has shape `[4, 1, 1, 3]` and value: ```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ``` (3) For the following input of shape `[1, 4, 4, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[4, 2, 2, 1]` and value: ```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ``` (4) For the following input of shape `[2, 2, 4, 1]` and block_size of 2: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[8, 1, 2, 1]` and value: ```prettyprint x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]], [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]] ``` Among others, this operation is useful for reducing atrous convolution into regular convolution.
block_size: An int
that is >= 2
.
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 space_to_batch_nd(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_batch_nd, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_batch_nd
Return
Applicative
Origial documentation for Builder.space_to_batch_nd
def space_to_batch_nd(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.space_to_batch_nd
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.space_to_batch_nd
def space_to_batch_nd(input, block_shape, paddings, name=None)
SpaceToBatch for N-D tensors of type T.
This operation divides "spatial" dimensions [1, ..., M]
of the input into a
grid of blocks of shape block_shape
, and interleaves these blocks with the
"batch" dimension (0) such that in the output, the spatial dimensions
[1, ..., M]
correspond to the position within the grid, and the batch
dimension combines both the position within a spatial block and the original
batch position. Prior to division into blocks, the spatial dimensions of the
input are optionally zero padded according to paddings
. See below for a
precise description.
Args:
input: A Tensor
.
N-D with shape input_shape = [batch] + spatial_shape + remaining_shape
,
where spatial_shape has M
dimensions.
block_shape: A Tensor
. Must be one of the following types: int32
, int64
.
1-D with shape [M]
, all values must be >= 1.
paddings: A Tensor
. Must be one of the following types: int32
, int64
.
2-D with shape [M, 2]
, all values must be >= 0.
paddings[i] = [pad_start, pad_end]
specifies the padding for input dimension
i + 1
, which corresponds to spatial dimension i
. It is required that
block_shape[i]
divides input_shape[i + 1] + pad_start + pad_end
.
This operation is equivalent to the following steps: 1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input according to `paddings` to produce `padded` of shape `padded_shape`. 2. Reshape `padded` to `reshaped_padded` of shape: [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ..., padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape 3. Permute dimensions of `reshaped_padded` to produce `permuted_reshaped_padded` of shape: block_shape + [batch] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape 4. Reshape `permuted_reshaped_padded` to flatten `block_shape` into the batch dimension, producing an output tensor of shape: [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape Some examples: (1) For the following input of shape `[1, 2, 2, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1], [2]], [[3], [4]]]] ``` The output tensor has shape `[4, 1, 1, 1]` and value: ```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ``` (2) For the following input of shape `[1, 2, 2, 3]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ``` The output tensor has shape `[4, 1, 1, 3]` and value: ```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ``` (3) For the following input of shape `[1, 4, 4, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[4, 2, 2, 1]` and value: ```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ``` (4) For the following input of shape `[2, 2, 4, 1]`, block_shape = `[2, 2]`, and paddings = `[[0, 0], [2, 0]]`: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[8, 1, 3, 1]` and value: ```prettyprint x = [[[[0], [1], [3]]], [[[0], [9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] ``` Among others, this operation is useful for reducing atrous convolution into regular convolution.
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 space_to_batch_nd_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_batch_nd_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_batch_nd_layer
Return
Applicative
Origial documentation for Builder.space_to_batch_nd_layer
def space_to_batch_nd_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.space_to_batch_nd, ...)
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.space_to_batch_nd
def space_to_batch_nd(input, block_shape, paddings, name=None):
SpaceToBatch for N-D tensors of type T.
This operation divides "spatial" dimensions [1, ..., M]
of the input into a
grid of blocks of shape block_shape
, and interleaves these blocks with the
"batch" dimension (0) such that in the output, the spatial dimensions
[1, ..., M]
correspond to the position within the grid, and the batch
dimension combines both the position within a spatial block and the original
batch position. Prior to division into blocks, the spatial dimensions of the
input are optionally zero padded according to paddings
. See below for a
precise description.
Args:
input: A Tensor
.
N-D with shape input_shape = [batch] + spatial_shape + remaining_shape
,
where spatial_shape has M
dimensions.
block_shape: A Tensor
. Must be one of the following types: int32
, int64
.
1-D with shape [M]
, all values must be >= 1.
paddings: A Tensor
. Must be one of the following types: int32
, int64
.
2-D with shape [M, 2]
, all values must be >= 0.
paddings[i] = [pad_start, pad_end]
specifies the padding for input dimension
i + 1
, which corresponds to spatial dimension i
. It is required that
block_shape[i]
divides input_shape[i + 1] + pad_start + pad_end
.
This operation is equivalent to the following steps: 1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input according to `paddings` to produce `padded` of shape `padded_shape`. 2. Reshape `padded` to `reshaped_padded` of shape: [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ..., padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape 3. Permute dimensions of `reshaped_padded` to produce `permuted_reshaped_padded` of shape: block_shape + [batch] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape 4. Reshape `permuted_reshaped_padded` to flatten `block_shape` into the batch dimension, producing an output tensor of shape: [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape Some examples: (1) For the following input of shape `[1, 2, 2, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1], [2]], [[3], [4]]]] ``` The output tensor has shape `[4, 1, 1, 1]` and value: ```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ``` (2) For the following input of shape `[1, 2, 2, 3]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ``` The output tensor has shape `[4, 1, 1, 3]` and value: ```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ``` (3) For the following input of shape `[1, 4, 4, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[4, 2, 2, 1]` and value: ```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ``` (4) For the following input of shape `[2, 2, 4, 1]`, block_shape = `[2, 2]`, and paddings = `[[0, 0], [2, 0]]`: ```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ``` The output tensor has shape `[8, 1, 3, 1]` and value: ```prettyprint x = [[[[0], [1], [3]]], [[[0], [9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] ``` Among others, this operation is useful for reducing atrous convolution into regular convolution.
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 space_to_depth(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_depth, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_depth
Return
Applicative
Origial documentation for Builder.space_to_depth
def space_to_depth(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.space_to_depth
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.space_to_depth
def space_to_depth(input, block_size, name=None)
SpaceToDepth for tensors of type T.
Rearranges blocks of spatial data, into depth. More specifically,
this op outputs a copy of the input tensor where values from the height
and width
dimensions are moved to the depth
dimension.
The attr block_size
indicates the input block size and how the data is moved.
- Non-overlapping blocks of size
block_size x block size
are rearranged into depth at each location. - The depth of the output tensor is
input_depth * block_size * block_size
. - The input tensor's height and width must be divisible by block_size.
That is, assuming the input is in the shape:
[batch, height, width, depth]
,
the shape of the output will be:
[batch, height/block_size, width/block_size, depth*block_size*block_size]
This operation requires that the input tensor be of rank 4, and that
block_size
be >=1 and a divisor of both the input height
and width
.
This operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models.
For example, given this input of shape [1, 2, 2, 1]
, and block_size of 2:
prettyprint
x = [[[[1], [2]],
[[3], [4]]]]
This operation will output a tensor of shape [1, 1, 1, 4]
:
prettyprint
[[[[1, 2, 3, 4]]]]
Here, the input has a batch of 1 and each batch element has shape [2, 2, 1]
,
the corresponding output will have a single element (i.e. width and height are
both 1) and will have a depth of 4 channels (1 * block_size * block_size).
The output element shape is [1, 1, 4]
.
For an input tensor with larger depth, here of shape [1, 2, 2, 3]
, e.g.
prettyprint
x = [[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]]]
This operation, for block_size of 2, will return the following tensor of shape
[1, 1, 1, 12]
prettyprint
[[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
Similarly, for the following input of shape [1 4 4 1]
, and a block size of 2:
prettyprint
x = [[[[1], [2], [5], [6]],
[[3], [4], [7], [8]],
[[9], [10], [13], [14]],
[[11], [12], [15], [16]]]]
the operator will return the following tensor of shape [1 2 2 4]
:
prettyprint
x = [[[[1, 2, 3, 4],
[5, 6, 7, 8]],
[[9, 10, 11, 12],
[13, 14, 15, 16]]]]
Args:
input: A Tensor
.
block_size: An int
that is >= 2
. The size of the spatial block.
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 space_to_depth_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.space_to_depth_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.space_to_depth_layer
Return
Applicative
Origial documentation for Builder.space_to_depth_layer
def space_to_depth_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.space_to_depth, ...)
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.space_to_depth
def space_to_depth(input, block_size, name=None):
SpaceToDepth for tensors of type T.
Rearranges blocks of spatial data, into depth. More specifically,
this op outputs a copy of the input tensor where values from the height
and width
dimensions are moved to the depth
dimension.
The attr block_size
indicates the input block size and how the data is moved.
- Non-overlapping blocks of size
block_size x block size
are rearranged into depth at each location. - The depth of the output tensor is
input_depth * block_size * block_size
. - The input tensor's height and width must be divisible by block_size.
That is, assuming the input is in the shape:
[batch, height, width, depth]
,
the shape of the output will be:
[batch, height/block_size, width/block_size, depth*block_size*block_size]
This operation requires that the input tensor be of rank 4, and that
block_size
be >=1 and a divisor of both the input height
and width
.
This operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models.
For example, given this input of shape [1, 2, 2, 1]
, and block_size of 2:
prettyprint
x = [[[[1], [2]],
[[3], [4]]]]
This operation will output a tensor of shape [1, 1, 1, 4]
:
prettyprint
[[[[1, 2, 3, 4]]]]
Here, the input has a batch of 1 and each batch element has shape [2, 2, 1]
,
the corresponding output will have a single element (i.e. width and height are
both 1) and will have a depth of 4 channels (1 * block_size * block_size).
The output element shape is [1, 1, 4]
.
For an input tensor with larger depth, here of shape [1, 2, 2, 3]
, e.g.
prettyprint
x = [[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]]]
This operation, for block_size of 2, will return the following tensor of shape
[1, 1, 1, 12]
prettyprint
[[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]
Similarly, for the following input of shape [1 4 4 1]
, and a block size of 2:
prettyprint
x = [[[[1], [2], [5], [6]],
[[3], [4], [7], [8]],
[[9], [10], [13], [14]],
[[11], [12], [15], [16]]]]
the operator will return the following tensor of shape [1 2 2 4]
:
prettyprint
x = [[[[1, 2, 3, 4],
[5, 6, 7, 8]],
[[9, 10, 11, 12],
[13, 14, 15, 16]]]]
Args:
input: A Tensor
.
block_size: An int
that is >= 2
. The size of the spatial block.
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 sparse_add(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_add, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_add
Return
Applicative
Origial documentation for Builder.sparse_add
def sparse_add(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_add
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.sparse_add
def sparse_add(a, b, thresh=0)
Adds two tensors, at least one of each is a SparseTensor
.
If one SparseTensor
and one Tensor
are passed in, returns a Tensor
. If
both arguments are SparseTensor
s, this returns a SparseTensor
. The order
of arguments does not matter. Use vanilla tf.add()
for adding two dense
Tensor
s.
The indices of any input SparseTensor
are assumed ordered in standard
lexicographic order. If this is not the case, before this step run
SparseReorder
to restore index ordering.
If both arguments are sparse, we perform "clipping" as follows. By default,
if two values sum to zero at some index, the output SparseTensor
would still
include that particular location in its index, storing a zero in the
corresponding value slot. To override this, callers can specify thresh
,
indicating that if the sum has a magnitude strictly smaller than thresh
, its
corresponding value and index would then not be included. In particular,
thresh == 0.0
(default) means everything is kept and actual thresholding
happens only for a positive value.
For example, suppose the logical sum of two sparse operands is (densified):
[ 2] [.1 0] [ 6 -.2]
Then,
- thresh == 0 (the default): all 5 index/value pairs will be returned. - thresh == 0.11: only .1 and 0 will vanish, and the remaining three index/value pairs will be returned. - thresh == 0.21: .1, 0, and -.2 will vanish.
Args:
a: The first operand; SparseTensor
or Tensor
.
b: The second operand; SparseTensor
or Tensor
. At least one operand
must be sparse.
thresh: A 0-D Tensor
. The magnitude threshold that determines if an
output value/index pair takes space. Its dtype should match that of the
values if they are real; if the latter are complex64/complex128, then the
dtype should be float32/float64, correspondingly.
Returns:
A SparseTensor
or a Tensor
, representing the sum.
Raises:
TypeError: If both a
and b
are Tensor
s. Use tf.add()
instead.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_add_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_add_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_add_layer
Return
Applicative
Origial documentation for Builder.sparse_add_layer
def sparse_add_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_add, ...)
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.sparse_add
def sparse_add(a, b, thresh=0):
Adds two tensors, at least one of each is a SparseTensor
.
If one SparseTensor
and one Tensor
are passed in, returns a Tensor
. If
both arguments are SparseTensor
s, this returns a SparseTensor
. The order
of arguments does not matter. Use vanilla tf.add()
for adding two dense
Tensor
s.
The indices of any input SparseTensor
are assumed ordered in standard
lexicographic order. If this is not the case, before this step run
SparseReorder
to restore index ordering.
If both arguments are sparse, we perform "clipping" as follows. By default,
if two values sum to zero at some index, the output SparseTensor
would still
include that particular location in its index, storing a zero in the
corresponding value slot. To override this, callers can specify thresh
,
indicating that if the sum has a magnitude strictly smaller than thresh
, its
corresponding value and index would then not be included. In particular,
thresh == 0.0
(default) means everything is kept and actual thresholding
happens only for a positive value.
For example, suppose the logical sum of two sparse operands is (densified):
[ 2] [.1 0] [ 6 -.2]
Then,
- thresh == 0 (the default): all 5 index/value pairs will be returned. - thresh == 0.11: only .1 and 0 will vanish, and the remaining three index/value pairs will be returned. - thresh == 0.21: .1, 0, and -.2 will vanish.
Args:
a: The first operand; SparseTensor
or Tensor
.
b: The second operand; SparseTensor
or Tensor
. At least one operand
must be sparse.
thresh: A 0-D Tensor
. The magnitude threshold that determines if an
output value/index pair takes space. Its dtype should match that of the
values if they are real; if the latter are complex64/complex128, then the
dtype should be float32/float64, correspondingly.
Returns:
A SparseTensor
or a Tensor
, representing the sum.
Raises:
TypeError: If both a
and b
are Tensor
s. Use tf.add()
instead.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_concat(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_concat, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_concat
Return
Applicative
Origial documentation for Builder.sparse_concat
def sparse_concat(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_concat
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.sparse_concat
def sparse_concat(concat_dim, sp_inputs, name=None, expand_nonconcat_dim=False)
Concatenates a list of SparseTensor
along the specified dimension.
Concatenation is with respect to the dense versions of each sparse input.
It is assumed that each inputs is a SparseTensor
whose elements are ordered
along increasing dimension number.
If expand_nonconcat_dim is False, all inputs' shapes must match, except for the concat dimension. If expand_nonconcat_dim is True, then inputs' shapes are allowd to vary among all inputs.
The indices
, values
, and shapes
lists must have the same length.
If expand_nonconcat_dim is False, then the output shape is identical to the inputs', except along the concat dimension, where it is the sum of the inputs' sizes along that dimension.
If expand_nonconcat_dim is True, then the output shape along the non-concat dimensions will be expand to be the largest among all inputs, and it is the sum of the inputs sizes along the concat dimension.
The output elements will be resorted to preserve the sort order along increasing dimension number.
This op runs in O(M log M)
time, where M
is the total number of non-empty
values across all inputs. This is due to the need for an internal sort in
order to concatenate efficiently across an arbitrary dimension.
For example, if concat_dim = 1
and the inputs are
sp_inputs[0]: shape = [2, 3] [0, 2]: "a" [1, 0]: "b" [1, 1]: "c" sp_inputs[1]: shape = [2, 4] [0, 1]: "d" [0, 2]: "e"
then the output will be
shape = [2, 7] [0, 2]: "a" [0, 4]: "d" [0, 5]: "e" [1, 0]: "b" [1, 1]: "c"
Graphically this is equivalent to doing
[ a] concat [ d e ] = [ a d e ] [b c ] [ ] [b c ]
Another example, if 'concat_dim = 1' and the inputs are
sp_inputs[0]: shape = [3, 3] [0, 2]: "a" [1, 0]: "b" [2, 1]: "c" sp_inputs[1]: shape = [2, 4] [0, 1]: "d" [0, 2]: "e"
if expand_nonconcat_dim = False, this will result in an error. But if expand_nonconcat_dim = True, this will result in:
shape = [3, 7] [0, 2]: "a" [0, 4]: "d" [0, 5]: "e" [1, 0]: "b" [2, 1]: "c"
Graphically this is equivalent to doing
[ a] concat [ d e ] = [ a d e ] [b ] [ ] [b ] [ c ] [ c ]
Args:
concat_dim: Dimension to concatenate along. Must be in range [-rank, rank),
where rank is the number of dimensions in each input SparseTensor
.
sp_inputs: List of SparseTensor
to concatenate.
name: A name prefix for the returned tensors (optional).
expand_nonconcat_dim: Whether to allow the expansion in the non-concat
dimensions. Defaulted to False.
Returns:
A SparseTensor
with the concatenated output.
Raises:
TypeError: If sp_inputs
is not a list of SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_concat_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_concat_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_concat_layer
Return
Applicative
Origial documentation for Builder.sparse_concat_layer
def sparse_concat_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_concat, ...)
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.sparse_concat
def sparse_concat(concat_dim, sp_inputs, name=None, expand_nonconcat_dim=False):
Concatenates a list of SparseTensor
along the specified dimension.
Concatenation is with respect to the dense versions of each sparse input.
It is assumed that each inputs is a SparseTensor
whose elements are ordered
along increasing dimension number.
If expand_nonconcat_dim is False, all inputs' shapes must match, except for the concat dimension. If expand_nonconcat_dim is True, then inputs' shapes are allowd to vary among all inputs.
The indices
, values
, and shapes
lists must have the same length.
If expand_nonconcat_dim is False, then the output shape is identical to the inputs', except along the concat dimension, where it is the sum of the inputs' sizes along that dimension.
If expand_nonconcat_dim is True, then the output shape along the non-concat dimensions will be expand to be the largest among all inputs, and it is the sum of the inputs sizes along the concat dimension.
The output elements will be resorted to preserve the sort order along increasing dimension number.
This op runs in O(M log M)
time, where M
is the total number of non-empty
values across all inputs. This is due to the need for an internal sort in
order to concatenate efficiently across an arbitrary dimension.
For example, if concat_dim = 1
and the inputs are
sp_inputs[0]: shape = [2, 3] [0, 2]: "a" [1, 0]: "b" [1, 1]: "c" sp_inputs[1]: shape = [2, 4] [0, 1]: "d" [0, 2]: "e"
then the output will be
shape = [2, 7] [0, 2]: "a" [0, 4]: "d" [0, 5]: "e" [1, 0]: "b" [1, 1]: "c"
Graphically this is equivalent to doing
[ a] concat [ d e ] = [ a d e ] [b c ] [ ] [b c ]
Another example, if 'concat_dim = 1' and the inputs are
sp_inputs[0]: shape = [3, 3] [0, 2]: "a" [1, 0]: "b" [2, 1]: "c" sp_inputs[1]: shape = [2, 4] [0, 1]: "d" [0, 2]: "e"
if expand_nonconcat_dim = False, this will result in an error. But if expand_nonconcat_dim = True, this will result in:
shape = [3, 7] [0, 2]: "a" [0, 4]: "d" [0, 5]: "e" [1, 0]: "b" [2, 1]: "c"
Graphically this is equivalent to doing
[ a] concat [ d e ] = [ a d e ] [b ] [ ] [b ] [ c ] [ c ]
Args:
concat_dim: Dimension to concatenate along. Must be in range [-rank, rank),
where rank is the number of dimensions in each input SparseTensor
.
sp_inputs: List of SparseTensor
to concatenate.
name: A name prefix for the returned tensors (optional).
expand_nonconcat_dim: Whether to allow the expansion in the non-concat
dimensions. Defaulted to False.
Returns:
A SparseTensor
with the concatenated output.
Raises:
TypeError: If sp_inputs
is not a list of SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_fill_empty_rows(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_fill_empty_rows, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_fill_empty_rows
Return
Applicative
Origial documentation for Builder.sparse_fill_empty_rows
def sparse_fill_empty_rows(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_fill_empty_rows
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.sparse_fill_empty_rows
def sparse_fill_empty_rows(sp_input, default_value, name=None)
Fills empty rows in the input 2-D SparseTensor
with a default value.
This op adds entries with the specified default_value
at index
[row, 0]
for any row in the input that does not already have a value.
For example, suppose sp_input
has shape [5, 6]
and non-empty values:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
Rows 1 and 4 are empty, so the output will be of shape [5, 6]
with values:
[0, 1]: a [0, 3]: b [1, 0]: default_value [2, 0]: c [3, 1]: d [4, 0]: default_value
Note that the input may have empty columns at the end, with no effect on this op.
The output SparseTensor
will be in row-major order and will have the
same shape as the input.
This op also returns an indicator vector such that
empty_row_indicator[i] = True iff row i was an empty row.
Args:
sp_input: A SparseTensor
with shape [N, M]
.
default_value: The value to fill for empty rows, with the same type as
sp_input.
name: A name prefix for the returned tensors (optional)
Returns:
sp_ordered_output: A SparseTensor
with shape [N, M]
, and with all empty
rows filled in with default_value
.
empty_row_indicator: A bool vector of length N
indicating whether each
input row was empty.
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_fill_empty_rows_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_fill_empty_rows_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_fill_empty_rows_layer
Return
Applicative
Origial documentation for Builder.sparse_fill_empty_rows_layer
def sparse_fill_empty_rows_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_fill_empty_rows, ...)
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.sparse_fill_empty_rows
def sparse_fill_empty_rows(sp_input, default_value, name=None):
Fills empty rows in the input 2-D SparseTensor
with a default value.
This op adds entries with the specified default_value
at index
[row, 0]
for any row in the input that does not already have a value.
For example, suppose sp_input
has shape [5, 6]
and non-empty values:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
Rows 1 and 4 are empty, so the output will be of shape [5, 6]
with values:
[0, 1]: a [0, 3]: b [1, 0]: default_value [2, 0]: c [3, 1]: d [4, 0]: default_value
Note that the input may have empty columns at the end, with no effect on this op.
The output SparseTensor
will be in row-major order and will have the
same shape as the input.
This op also returns an indicator vector such that
empty_row_indicator[i] = True iff row i was an empty row.
Args:
sp_input: A SparseTensor
with shape [N, M]
.
default_value: The value to fill for empty rows, with the same type as
sp_input.
name: A name prefix for the returned tensors (optional)
Returns:
sp_ordered_output: A SparseTensor
with shape [N, M]
, and with all empty
rows filled in with default_value
.
empty_row_indicator: A bool vector of length N
indicating whether each
input row was empty.
Raises:
TypeError: If sp_input
is not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_mask(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_mask, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_mask
Return
Applicative
Origial documentation for Builder.sparse_mask
def sparse_mask(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_mask
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.sparse_mask
def sparse_mask(a, mask_indices, name=None)
Masks elements of IndexedSlices
.
Given an IndexedSlices
instance a
, returns another IndexedSlices
that
contains a subset of the slices of a
. Only the slices at indices not
specified in mask_indices
are returned.
This is useful when you need to extract a subset of slices in an
IndexedSlices
object.
For example:
```python
a
contains slices at indices [12, 26, 37, 45] from a large tensor
with shape [1000, 10]
a.indices => [12, 26, 37, 45] tf.shape(a.values) => [4, 10]
b
will be the subset of a
slices at its second and third indices, so
we want to mask its first and last indices (which are at absolute
indices 12, 45)
b = tf.sparse_mask(a, [12, 45])
b.indices => [26, 37] tf.shape(b.values) => [2, 10]
```
Args:
* a
: An IndexedSlices
instance.
* mask_indices
: Indices of elements to mask.
* name
: A name for the operation (optional).
Returns:
The masked IndexedSlices
instance.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_mask_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_mask_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_mask_layer
Return
Applicative
Origial documentation for Builder.sparse_mask_layer
def sparse_mask_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_mask, ...)
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.sparse_mask
def sparse_mask(a, mask_indices, name=None):
Masks elements of IndexedSlices
.
Given an IndexedSlices
instance a
, returns another IndexedSlices
that
contains a subset of the slices of a
. Only the slices at indices not
specified in mask_indices
are returned.
This is useful when you need to extract a subset of slices in an
IndexedSlices
object.
For example:
```python
a
contains slices at indices [12, 26, 37, 45] from a large tensor
with shape [1000, 10]
a.indices => [12, 26, 37, 45] tf.shape(a.values) => [4, 10]
b
will be the subset of a
slices at its second and third indices, so
we want to mask its first and last indices (which are at absolute
indices 12, 45)
b = tf.sparse_mask(a, [12, 45])
b.indices => [26, 37] tf.shape(b.values) => [2, 10]
```
Args:
* a
: An IndexedSlices
instance.
* mask_indices
: Indices of elements to mask.
* name
: A name for the operation (optional).
Returns:
The masked IndexedSlices
instance.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_matmul_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_matmul_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_matmul_layer
Return
Applicative
Origial documentation for Builder.sparse_matmul_layer
def sparse_matmul_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_matmul, ...)
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.sparse_matmul
def _sparse_mat_mul(a, b, transpose_a=None, transpose_b=None, a_is_sparse=None, b_is_sparse=None, name=None):
Multiply matrix "a" by matrix "b".
The inputs must be two-dimensional matrices and the inner dimension of "a" must match the outer dimension of "b". This op is optimized for the case where at least one of "a" or "b" is sparse. The breakeven for using this versus a dense matrix multiply on one platform was 30% zero values in the sparse matrix.
Args:
a: A Tensor
. Must be one of the following types: float32
, bfloat16
.
b: A Tensor
. Must be one of the following types: float32
, bfloat16
.
transpose_a: An optional bool
. Defaults to False
.
transpose_b: An optional bool
. Defaults to False
.
a_is_sparse: An optional bool
. Defaults to False
.
b_is_sparse: An optional bool
. Defaults to False
.
name: A name for the operation (optional).
Returns:
A Tensor
of type float32
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_maximum(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_maximum, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_maximum
Return
Applicative
Origial documentation for Builder.sparse_maximum
def sparse_maximum(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_maximum
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.sparse_maximum
def sparse_maximum(sp_a, sp_b, name=None)
Returns the element-wise max of two SparseTensors.
Assumes the two SparseTensors have the same shape, i.e., no broadcasting. Example:
```python sp_zero = ops.SparseTensor([[0]], [0], [7]) sp_one = ops.SparseTensor([[1]], [1], [7]) res = tf.sparse_maximum(sp_zero, sp_one).eval()
"res" should be equal to SparseTensor([[0], [1]], [0, 1], [7]).
```
Args:
sp_a: a SparseTensor
operand whose dtype is real, and indices
lexicographically ordered.
sp_b: the other SparseTensor
operand with the same requirements (and the
same shape).
name: optional name of the operation.
Returns:
output: the output SparseTensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_maximum_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_maximum_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_maximum_layer
Return
Applicative
Origial documentation for Builder.sparse_maximum_layer
def sparse_maximum_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_maximum, ...)
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.sparse_maximum
def sparse_maximum(sp_a, sp_b, name=None):
Returns the element-wise max of two SparseTensors.
Assumes the two SparseTensors have the same shape, i.e., no broadcasting. Example:
```python sp_zero = ops.SparseTensor([[0]], [0], [7]) sp_one = ops.SparseTensor([[1]], [1], [7]) res = tf.sparse_maximum(sp_zero, sp_one).eval()
"res" should be equal to SparseTensor([[0], [1]], [0, 1], [7]).
```
Args:
sp_a: a SparseTensor
operand whose dtype is real, and indices
lexicographically ordered.
sp_b: the other SparseTensor
operand with the same requirements (and the
same shape).
name: optional name of the operation.
Returns:
output: the output SparseTensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_merge(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_merge, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_merge
Return
Applicative
Origial documentation for Builder.sparse_merge
def sparse_merge(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_merge
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.sparse_merge
def sparse_merge(sp_ids, sp_values, vocab_size, name=None, already_sorted=False)
Combines a batch of feature ids and values into a single SparseTensor
.
The most common use case for this function occurs when feature ids and
their corresponding values are stored in Example
protos on disk.
parse_example
will return a batch of ids and a batch of values, and this
function joins them into a single logical SparseTensor
for use in
functions such as sparse_tensor_dense_matmul
, sparse_to_dense
, etc.
The SparseTensor
returned by this function has the following properties:
indices
is equivalent tosp_ids.indices
with the last dimension discarded and replaced withsp_ids.values
.values
is simplysp_values.values
.- If
sp_ids.shape = [D0, D1, ..., Dn, K]
, thenoutput.shape = [D0, D1, ..., Dn, vocab_size]
.
For example, consider the following feature vectors:
python
vector1 = [-3, 0, 0, 0, 0, 0]
vector2 = [ 0, 1, 0, 4, 1, 0]
vector3 = [ 5, 0, 0, 9, 0, 0]
These might be stored sparsely in the following Example protos by storing only the feature ids (column number if the vectors are treated as a matrix) of the non-zero elements and the corresponding values:
python
examples = [Example(features={
"ids": Feature(int64_list=Int64List(value=[0])),
"values": Feature(float_list=FloatList(value=[-3]))}),
Example(features={
"ids": Feature(int64_list=Int64List(value=[1, 4, 3])),
"values": Feature(float_list=FloatList(value=[1, 1, 4]))}),
Example(features={
"ids": Feature(int64_list=Int64List(value=[0, 3])),
"values": Feature(float_list=FloatList(value=[5, 9]))})]
The result of calling parse_example on these examples will produce a
dictionary with entries for "ids" and "values". Passing those two objects
to this function along with vocab_size=6, will produce a SparseTensor
that
sparsely represents all three instances. Namely, the indices
property will
contain the coordinates of the non-zero entries in the feature matrix (the
first dimension is the row number in the matrix, i.e., the index within the
batch, and the second dimension is the column number, i.e., the feature id);
values
will contain the actual values. shape
will be the shape of the
original matrix, i.e., (3, 6). For our example above, the output will be
equal to:
python
SparseTensor(indices=[[0, 0], [1, 1], [1, 3], [1, 4], [2, 0], [2, 3]],
values=[-3, 1, 4, 1, 5, 9],
shape=[3, 6])
Args:
sp_ids: A SparseTensor
with values
property of type int32
or int64
.
sp_values: ASparseTensor
of any type.
vocab_size: A scalar int64
Tensor (or Python int) containing the new size
of the last dimension, all(0 <= sp_ids.values < vocab_size)
.
name: A name prefix for the returned tensors (optional)
already_sorted: A boolean to specify whether the per-batch values in
sp_values
are already sorted. If so skip sorting, False by default
(optional).
Returns:
A SparseTensor
compactly representing a batch of feature ids and values,
useful for passing to functions that expect such a SparseTensor
.
Raises:
TypeError: If sp_ids
or sp_values
are not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_merge_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_merge_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_merge_layer
Return
Applicative
Origial documentation for Builder.sparse_merge_layer
def sparse_merge_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_merge, ...)
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.sparse_merge
def sparse_merge(sp_ids, sp_values, vocab_size, name=None, already_sorted=False):
Combines a batch of feature ids and values into a single SparseTensor
.
The most common use case for this function occurs when feature ids and
their corresponding values are stored in Example
protos on disk.
parse_example
will return a batch of ids and a batch of values, and this
function joins them into a single logical SparseTensor
for use in
functions such as sparse_tensor_dense_matmul
, sparse_to_dense
, etc.
The SparseTensor
returned by this function has the following properties:
indices
is equivalent tosp_ids.indices
with the last dimension discarded and replaced withsp_ids.values
.values
is simplysp_values.values
.- If
sp_ids.shape = [D0, D1, ..., Dn, K]
, thenoutput.shape = [D0, D1, ..., Dn, vocab_size]
.
For example, consider the following feature vectors:
python
vector1 = [-3, 0, 0, 0, 0, 0]
vector2 = [ 0, 1, 0, 4, 1, 0]
vector3 = [ 5, 0, 0, 9, 0, 0]
These might be stored sparsely in the following Example protos by storing only the feature ids (column number if the vectors are treated as a matrix) of the non-zero elements and the corresponding values:
python
examples = [Example(features={
"ids": Feature(int64_list=Int64List(value=[0])),
"values": Feature(float_list=FloatList(value=[-3]))}),
Example(features={
"ids": Feature(int64_list=Int64List(value=[1, 4, 3])),
"values": Feature(float_list=FloatList(value=[1, 1, 4]))}),
Example(features={
"ids": Feature(int64_list=Int64List(value=[0, 3])),
"values": Feature(float_list=FloatList(value=[5, 9]))})]
The result of calling parse_example on these examples will produce a
dictionary with entries for "ids" and "values". Passing those two objects
to this function along with vocab_size=6, will produce a SparseTensor
that
sparsely represents all three instances. Namely, the indices
property will
contain the coordinates of the non-zero entries in the feature matrix (the
first dimension is the row number in the matrix, i.e., the index within the
batch, and the second dimension is the column number, i.e., the feature id);
values
will contain the actual values. shape
will be the shape of the
original matrix, i.e., (3, 6). For our example above, the output will be
equal to:
python
SparseTensor(indices=[[0, 0], [1, 1], [1, 3], [1, 4], [2, 0], [2, 3]],
values=[-3, 1, 4, 1, 5, 9],
shape=[3, 6])
Args:
sp_ids: A SparseTensor
with values
property of type int32
or int64
.
sp_values: ASparseTensor
of any type.
vocab_size: A scalar int64
Tensor (or Python int) containing the new size
of the last dimension, all(0 <= sp_ids.values < vocab_size)
.
name: A name prefix for the returned tensors (optional)
already_sorted: A boolean to specify whether the per-batch values in
sp_values
are already sorted. If so skip sorting, False by default
(optional).
Returns:
A SparseTensor
compactly representing a batch of feature ids and values,
useful for passing to functions that expect such a SparseTensor
.
Raises:
TypeError: If sp_ids
or sp_values
are not a SparseTensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_minimum(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_minimum, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_minimum
Return
Applicative
Origial documentation for Builder.sparse_minimum
def sparse_minimum(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_minimum
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.sparse_minimum
def sparse_minimum(sp_a, sp_b, name=None)
Returns the element-wise min of two SparseTensors.
Assumes the two SparseTensors have the same shape, i.e., no broadcasting. Example:
```python sp_zero = ops.SparseTensor([[0]], [0], [7]) sp_one = ops.SparseTensor([[1]], [1], [7]) res = tf.sparse_minimum(sp_zero, sp_one).eval()
"res" should be equal to SparseTensor([[0], [1]], [0, 0], [7]).
```
Args:
sp_a: a SparseTensor
operand whose dtype is real, and indices
lexicographically ordered.
sp_b: the other SparseTensor
operand with the same requirements (and the
same shape).
name: optional name of the operation.
Returns:
output: the output SparseTensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_minimum_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_minimum_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_minimum_layer
Return
Applicative
Origial documentation for Builder.sparse_minimum_layer
def sparse_minimum_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_minimum, ...)
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.sparse_minimum
def sparse_minimum(sp_a, sp_b, name=None):
Returns the element-wise min of two SparseTensors.
Assumes the two SparseTensors have the same shape, i.e., no broadcasting. Example:
```python sp_zero = ops.SparseTensor([[0]], [0], [7]) sp_one = ops.SparseTensor([[1]], [1], [7]) res = tf.sparse_minimum(sp_zero, sp_one).eval()
"res" should be equal to SparseTensor([[0], [1]], [0, 0], [7]).
```
Args:
sp_a: a SparseTensor
operand whose dtype is real, and indices
lexicographically ordered.
sp_b: the other SparseTensor
operand with the same requirements (and the
same shape).
name: optional name of the operation.
Returns:
output: the output SparseTensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_placeholder(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_placeholder, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_placeholder
Return
Applicative
Origial documentation for Builder.sparse_placeholder
def sparse_placeholder(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_placeholder
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.sparse_placeholder
def sparse_placeholder(dtype, shape=None, name=None)
Inserts a placeholder for a sparse tensor that will be always fed.
Important: This sparse tensor will produce an error if evaluated.
Its value must be fed using the feed_dict
optional argument to
Session.run()
, Tensor.eval()
, or Operation.run()
.
For example:
```python x = tf.sparse_placeholder(tf.float32) y = tf.sparse_reduce_sum(x)
with tf.Session() as sess: print(sess.run(y)) # ERROR: will fail because x was not fed.
indices = np.array([[3, 2, 0], [4, 5, 1]], dtype=np.int64) values = np.array([1.0, 2.0], dtype=np.float32) shape = np.array([7, 9, 2], dtype=np.int64) print(sess.run(y, feed_dict={ x: tf.SparseTensorValue(indices, values, shape)})) # Will succeed. print(sess.run(y, feed_dict={ x: (indices, values, shape)})) # Will succeed.
sp = tf.SparseTensor(indices=indices, values=values, shape=shape) sp_value = sp.eval(session) print(sess.run(y, feed_dict={x: sp_value})) # Will succeed. ```
Args:
dtype: The type of values
elements in the tensor to be fed.
shape: The shape of the tensor to be fed (optional). If the shape is not
specified, you can feed a sparse tensor of any shape.
name: A name for prefixing the operations (optional).
Returns:
A SparseTensor
that may be used as a handle for feeding a value, but not
evaluated directly.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_placeholder_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_placeholder_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_placeholder_layer
Return
Applicative
Origial documentation for Builder.sparse_placeholder_layer
def sparse_placeholder_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_placeholder, ...)
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.sparse_placeholder
def sparse_placeholder(dtype, shape=None, name=None):
Inserts a placeholder for a sparse tensor that will be always fed.
Important: This sparse tensor will produce an error if evaluated.
Its value must be fed using the feed_dict
optional argument to
Session.run()
, Tensor.eval()
, or Operation.run()
.
For example:
```python x = tf.sparse_placeholder(tf.float32) y = tf.sparse_reduce_sum(x)
with tf.Session() as sess: print(sess.run(y)) # ERROR: will fail because x was not fed.
indices = np.array([[3, 2, 0], [4, 5, 1]], dtype=np.int64) values = np.array([1.0, 2.0], dtype=np.float32) shape = np.array([7, 9, 2], dtype=np.int64) print(sess.run(y, feed_dict={ x: tf.SparseTensorValue(indices, values, shape)})) # Will succeed. print(sess.run(y, feed_dict={ x: (indices, values, shape)})) # Will succeed.
sp = tf.SparseTensor(indices=indices, values=values, shape=shape) sp_value = sp.eval(session) print(sess.run(y, feed_dict={x: sp_value})) # Will succeed. ```
Args:
dtype: The type of values
elements in the tensor to be fed.
shape: The shape of the tensor to be fed (optional). If the shape is not
specified, you can feed a sparse tensor of any shape.
name: A name for prefixing the operations (optional).
Returns:
A SparseTensor
that may be used as a handle for feeding a value, but not
evaluated directly.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_reduce_sum(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reduce_sum, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reduce_sum
Return
Applicative
Origial documentation for Builder.sparse_reduce_sum
def sparse_reduce_sum(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_reduce_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.sparse_reduce_sum
def sparse_reduce_sum(sp_input, reduction_axes=None, keep_dims=False)
Computes the sum of elements across dimensions of a SparseTensor.
This Op takes a SparseTensor and is the sparse counterpart to
tf.reduce_sum()
. In particular, this Op also returns a dense Tensor
instead of a sparse one.
Reduces sp_input
along the dimensions given in reduction_axes
. Unless
keep_dims