is true, the rank of the tensor is reduced by 1 for each entry in
reduction_axes
. If keep_dims
is true, the reduced dimensions are retained
with length 1.
If reduction_axes
has no entries, all dimensions are reduced, and a tensor
with a single element is returned. Additionally, the axes can be negative,
similar to the indexing rules in Python.
For example:
```python
'x' represents [[1, ?, 1]
[?, 1, ?]]
where ? is implicitly-zero.
tf.sparse_reduce_sum(x) ==> 3 tf.sparse_reduce_sum(x, 0) ==> [1, 1, 1] tf.sparse_reduce_sum(x, 1) ==> [2, 1] # Can also use -1 as the axis. tf.sparse_reduce_sum(x, 1, keep_dims=True) ==> [[2], [1]] tf.sparse_reduce_sum(x, [0, 1]) ==> 3 ```
Args:
sp_input: The SparseTensor to reduce. Should have numeric type.
reduction_axes: The dimensions to reduce; list or scalar. If None
(the
default), reduces all dimensions.
keep_dims: If true, retain reduced dimensions with length 1.
Returns: The reduced Tensor.
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_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reduce_sum_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reduce_sum_layer
Return
Applicative
Origial documentation for Builder.sparse_reduce_sum_layer
def sparse_reduce_sum_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_reduce_sum, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.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
is true, the rank of the tensor is reduced by 1 for each entry in
reduction_axes
. If keep_dims
is true, the reduced dimensions are retained
with length 1.
If reduction_axes
has no entries, all dimensions are reduced, and a tensor
with a single element is returned. Additionally, the axes can be negative,
similar to the indexing rules in Python.
For example:
```python
'x' represents [[1, ?, 1]
[?, 1, ?]]
where ? is implicitly-zero.
tf.sparse_reduce_sum(x) ==> 3 tf.sparse_reduce_sum(x, 0) ==> [1, 1, 1] tf.sparse_reduce_sum(x, 1) ==> [2, 1] # Can also use -1 as the axis. tf.sparse_reduce_sum(x, 1, keep_dims=True) ==> [[2], [1]] tf.sparse_reduce_sum(x, [0, 1]) ==> 3 ```
Args:
sp_input: The SparseTensor to reduce. Should have numeric type.
reduction_axes: The dimensions to reduce; list or scalar. If None
(the
default), reduces all dimensions.
keep_dims: If true, retain reduced dimensions with length 1.
Returns: The reduced Tensor.
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_sparse(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reduce_sum_sparse, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reduce_sum_sparse
Return
Applicative
Origial documentation for Builder.sparse_reduce_sum_sparse
def sparse_reduce_sum_sparse(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_reduce_sum_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.sparse_reduce_sum_sparse
def sparse_reduce_sum_sparse(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 contrast to SparseReduceSum, this Op returns a
SparseTensor.
Reduces sp_input
along the dimensions given in reduction_axes
. Unless
keep_dims
is true, the rank of the tensor is reduced by 1 for each entry in
reduction_axes
. If keep_dims
is true, the reduced dimensions are retained
with length 1.
If reduction_axes
has no entries, all dimensions are reduced, and a tensor
with a single element is returned. Additionally, the axes can be negative,
which are interpreted according to the indexing rules in Python.
Args:
sp_input: The SparseTensor to reduce. Should have numeric type.
reduction_axes: The dimensions to reduce; list or scalar. If None
(the
default), reduces all dimensions.
keep_dims: If true, retain reduced dimensions with length 1.
Returns: The reduced SparseTensor.
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_sparse_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reduce_sum_sparse_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reduce_sum_sparse_layer
Return
Applicative
Origial documentation for Builder.sparse_reduce_sum_sparse_layer
def sparse_reduce_sum_sparse_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_reduce_sum_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.sparse_reduce_sum_sparse
def sparse_reduce_sum_sparse(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 contrast to SparseReduceSum, this Op returns a
SparseTensor.
Reduces sp_input
along the dimensions given in reduction_axes
. Unless
keep_dims
is true, the rank of the tensor is reduced by 1 for each entry in
reduction_axes
. If keep_dims
is true, the reduced dimensions are retained
with length 1.
If reduction_axes
has no entries, all dimensions are reduced, and a tensor
with a single element is returned. Additionally, the axes can be negative,
which are interpreted according to the indexing rules in Python.
Args:
sp_input: The SparseTensor to reduce. Should have numeric type.
reduction_axes: The dimensions to reduce; list or scalar. If None
(the
default), reduces all dimensions.
keep_dims: If true, retain reduced dimensions with length 1.
Returns: The reduced SparseTensor.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_reorder(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reorder, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reorder
Return
Applicative
Origial documentation for Builder.sparse_reorder
def sparse_reorder(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_reorder
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_reorder
def sparse_reorder(sp_input, name=None)
Reorders a SparseTensor
into the canonical, row-major ordering.
Note that by convention, all sparse ops preserve the canonical ordering along increasing dimension number. The only time ordering can be violated is during manual manipulation of the indices and values to add entries.
Reordering does not affect the shape of the SparseTensor
.
For example, if sp_input
has shape [4, 5]
and indices
/ values
:
[0, 3]: b [0, 1]: a [3, 1]: d [2, 0]: c
then the output will be a SparseTensor
of shape [4, 5]
and
indices
/ values
:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
Args:
sp_input: The input SparseTensor
.
name: A name prefix for the returned tensors (optional)
Returns:
A SparseTensor
with the same shape and non-empty values, but in
canonical ordering.
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_reorder_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reorder_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reorder_layer
Return
Applicative
Origial documentation for Builder.sparse_reorder_layer
def sparse_reorder_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_reorder, ...)
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_reorder
def sparse_reorder(sp_input, name=None):
Reorders a SparseTensor
into the canonical, row-major ordering.
Note that by convention, all sparse ops preserve the canonical ordering along increasing dimension number. The only time ordering can be violated is during manual manipulation of the indices and values to add entries.
Reordering does not affect the shape of the SparseTensor
.
For example, if sp_input
has shape [4, 5]
and indices
/ values
:
[0, 3]: b [0, 1]: a [3, 1]: d [2, 0]: c
then the output will be a SparseTensor
of shape [4, 5]
and
indices
/ values
:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
Args:
sp_input: The input SparseTensor
.
name: A name prefix for the returned tensors (optional)
Returns:
A SparseTensor
with the same shape and non-empty values, but in
canonical ordering.
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_reset_shape(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reset_shape, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reset_shape
Return
Applicative
Origial documentation for Builder.sparse_reset_shape
def sparse_reset_shape(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_reset_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.sparse_reset_shape
def sparse_reset_shape(sp_input, new_shape=None)
Resets the shape of a SparseTensor
with indices and values unchanged.
If new_shape
is None, returns a copy of sp_input
with its shape reset
to the tight bounding box of sp_input
.
If new_shape
is provided, then it must be larger or equal in all dimensions
compared to the shape of sp_input
. When this condition is met, the returned
SparseTensor will have its shape reset to new_shape
and its indices and
values unchanged from that of sp_input.
For example:
Consider a sp_input
with shape [2, 3, 5]:
[0, 0, 1]: a [0, 1, 0]: b [0, 2, 2]: c [1, 0, 3]: d
-
It is an error to set
new_shape
as [3, 7] since this represents a rank-2 tensor whilesp_input
is rank-3. This is either a ValueError during graph construction (if both shapes are known) or an OpError during run time. -
Setting
new_shape
as [2, 3, 6] will be fine as this shape is larger or equal in every dimension compared to the original shape [2, 3, 5]. -
On the other hand, setting new_shape as [2, 3, 4] is also an error: The third dimension is smaller than the original shape [2, 3, 5] (and an
InvalidArgumentError
will be raised). -
If
new_shape
is None, the returned SparseTensor will have a shape [2, 3, 4], which is the tight bounding box ofsp_input
.
Args:
sp_input: The input SparseTensor
.
new_shape: None or a vector representing the new shape for the returned
SparseTensor
.
Returns:
A SparseTensor
indices and values unchanged from input_sp
. Its shape is
new_shape
if that is set. Otherwise it is the tight bounding box of
input_sp
Raises:
TypeError: If sp_input
is not a SparseTensor
.
ValueError: If new_shape
represents a tensor with a different rank from
that of sp_input
(if shapes are known when graph is constructed).
OpError:
- If new_shape
has dimension sizes that are too small.
- If shapes are not known during graph construction time, and during run
time it is found out that the ranks do not match.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_reset_shape_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reset_shape_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reset_shape_layer
Return
Applicative
Origial documentation for Builder.sparse_reset_shape_layer
def sparse_reset_shape_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_reset_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.sparse_reset_shape
def sparse_reset_shape(sp_input, new_shape=None):
Resets the shape of a SparseTensor
with indices and values unchanged.
If new_shape
is None, returns a copy of sp_input
with its shape reset
to the tight bounding box of sp_input
.
If new_shape
is provided, then it must be larger or equal in all dimensions
compared to the shape of sp_input
. When this condition is met, the returned
SparseTensor will have its shape reset to new_shape
and its indices and
values unchanged from that of sp_input.
For example:
Consider a sp_input
with shape [2, 3, 5]:
[0, 0, 1]: a [0, 1, 0]: b [0, 2, 2]: c [1, 0, 3]: d
-
It is an error to set
new_shape
as [3, 7] since this represents a rank-2 tensor whilesp_input
is rank-3. This is either a ValueError during graph construction (if both shapes are known) or an OpError during run time. -
Setting
new_shape
as [2, 3, 6] will be fine as this shape is larger or equal in every dimension compared to the original shape [2, 3, 5]. -
On the other hand, setting new_shape as [2, 3, 4] is also an error: The third dimension is smaller than the original shape [2, 3, 5] (and an
InvalidArgumentError
will be raised). -
If
new_shape
is None, the returned SparseTensor will have a shape [2, 3, 4], which is the tight bounding box ofsp_input
.
Args:
sp_input: The input SparseTensor
.
new_shape: None or a vector representing the new shape for the returned
SparseTensor
.
Returns:
A SparseTensor
indices and values unchanged from input_sp
. Its shape is
new_shape
if that is set. Otherwise it is the tight bounding box of
input_sp
Raises:
TypeError: If sp_input
is not a SparseTensor
.
ValueError: If new_shape
represents a tensor with a different rank from
that of sp_input
(if shapes are known when graph is constructed).
OpError:
- If new_shape
has dimension sizes that are too small.
- If shapes are not known during graph construction time, and during run
time it is found out that the ranks do not match.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_reshape(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reshape, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reshape
Return
Applicative
Origial documentation for Builder.sparse_reshape
def sparse_reshape(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_reshape
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_reshape
def sparse_reshape(sp_input, shape, name=None)
Reshapes a SparseTensor
to represent values in a new dense shape.
This operation has the same semantics as reshape
on the represented dense
tensor. The indices of non-empty values in sp_input
are recomputed based
on the new dense shape, and a new SparseTensor
is returned containing the
new indices and new shape. The order of non-empty values in sp_input
is
unchanged.
If one component of shape
is the special value -1, the size of that
dimension is computed so that the total dense size remains constant. At
most one component of shape
can be -1. The number of dense elements
implied by shape
must be the same as the number of dense elements
originally represented by sp_input
.
For example, if sp_input
has shape [2, 3, 6]
and indices
/ values
:
[0, 0, 0]: a [0, 0, 1]: b [0, 1, 0]: c [1, 0, 0]: d [1, 2, 3]: e
and shape
is [9, -1]
, then the output will be a SparseTensor
of
shape [9, 4]
and indices
/ values
:
[0, 0]: a [0, 1]: b [1, 2]: c [4, 2]: d [8, 1]: e
Args:
sp_input: The input SparseTensor
.
shape: A 1-D (vector) int64 Tensor
specifying the new dense shape of the
represented SparseTensor
.
name: A name prefix for the returned tensors (optional)
Returns:
A SparseTensor
with the same non-empty values but with indices calculated
by the new dense shape.
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_reshape_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_reshape_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_reshape_layer
Return
Applicative
Origial documentation for Builder.sparse_reshape_layer
def sparse_reshape_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_reshape, ...)
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_reshape
def sparse_reshape(sp_input, shape, name=None):
Reshapes a SparseTensor
to represent values in a new dense shape.
This operation has the same semantics as reshape
on the represented dense
tensor. The indices of non-empty values in sp_input
are recomputed based
on the new dense shape, and a new SparseTensor
is returned containing the
new indices and new shape. The order of non-empty values in sp_input
is
unchanged.
If one component of shape
is the special value -1, the size of that
dimension is computed so that the total dense size remains constant. At
most one component of shape
can be -1. The number of dense elements
implied by shape
must be the same as the number of dense elements
originally represented by sp_input
.
For example, if sp_input
has shape [2, 3, 6]
and indices
/ values
:
[0, 0, 0]: a [0, 0, 1]: b [0, 1, 0]: c [1, 0, 0]: d [1, 2, 3]: e
and shape
is [9, -1]
, then the output will be a SparseTensor
of
shape [9, 4]
and indices
/ values
:
[0, 0]: a [0, 1]: b [1, 2]: c [4, 2]: d [8, 1]: e
Args:
sp_input: The input SparseTensor
.
shape: A 1-D (vector) int64 Tensor
specifying the new dense shape of the
represented SparseTensor
.
name: A name prefix for the returned tensors (optional)
Returns:
A SparseTensor
with the same non-empty values but with indices calculated
by the new dense shape.
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_retain(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_retain, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_retain
Return
Applicative
Origial documentation for Builder.sparse_retain
def sparse_retain(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_retain
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_retain
def sparse_retain(sp_input, to_retain)
Retains specified non-empty values within a SparseTensor
.
For example, if sp_input
has shape [4, 5]
and 4 non-empty string values:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
and to_retain = [True, False, False, True]
, then the output will
be a SparseTensor
of shape [4, 5]
with 2 non-empty values:
[0, 1]: a [3, 1]: d
Args:
sp_input: The input SparseTensor
with N
non-empty elements.
to_retain: A bool vector of length N
with M
true values.
Returns:
A SparseTensor
with the same shape as the input and M
non-empty
elements corresponding to the true positions in to_retain
.
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_retain_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_retain_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_retain_layer
Return
Applicative
Origial documentation for Builder.sparse_retain_layer
def sparse_retain_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_retain, ...)
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_retain
def sparse_retain(sp_input, to_retain):
Retains specified non-empty values within a SparseTensor
.
For example, if sp_input
has shape [4, 5]
and 4 non-empty string values:
[0, 1]: a [0, 3]: b [2, 0]: c [3, 1]: d
and to_retain = [True, False, False, True]
, then the output will
be a SparseTensor
of shape [4, 5]
with 2 non-empty values:
[0, 1]: a [3, 1]: d
Args:
sp_input: The input SparseTensor
with N
non-empty elements.
to_retain: A bool vector of length N
with M
true values.
Returns:
A SparseTensor
with the same shape as the input and M
non-empty
elements corresponding to the true positions in to_retain
.
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_segment_mean(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_mean, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_mean
Return
Applicative
Origial documentation for Builder.sparse_segment_mean
def sparse_segment_mean(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_segment_mean
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_segment_mean
def sparse_segment_mean(data, indices, segment_ids, name=None)
Computes the mean along sparse segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Like SegmentMean
, but segment_ids
can have rank less than data
's first
dimension, selecting a subset of dimension 0, specified by indices
.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_segment_mean_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_mean_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_mean_layer
Return
Applicative
Origial documentation for Builder.sparse_segment_mean_layer
def sparse_segment_mean_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_segment_mean, ...)
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_segment_mean
def sparse_segment_mean(data, indices, segment_ids, name=None):
Computes the mean along sparse segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Like SegmentMean
, but segment_ids
can have rank less than data
's first
dimension, selecting a subset of dimension 0, specified by indices
.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_segment_sqrt_n(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_sqrt_n, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_sqrt_n
Return
Applicative
Origial documentation for Builder.sparse_segment_sqrt_n
def sparse_segment_sqrt_n(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_segment_sqrt_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.sparse_segment_sqrt_n
def sparse_segment_sqrt_n(data, indices, segment_ids, name=None)
Computes the sum along sparse segments of a tensor divided by the sqrt of N.
N is the size of the segment being reduced.
Read the section on Segmentation for an explanation of segments.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_segment_sqrt_n_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_sqrt_n_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_sqrt_n_layer
Return
Applicative
Origial documentation for Builder.sparse_segment_sqrt_n_layer
def sparse_segment_sqrt_n_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_segment_sqrt_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.sparse_segment_sqrt_n
def sparse_segment_sqrt_n(data, indices, segment_ids, name=None):
Computes the sum along sparse segments of a tensor divided by the sqrt of N.
N is the size of the segment being reduced.
Read the section on Segmentation for an explanation of segments.
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_segment_sum(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_sum, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_sum
Return
Applicative
Origial documentation for Builder.sparse_segment_sum
def sparse_segment_sum(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_segment_sum
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.sparse_segment_sum
def sparse_segment_sum(data, indices, segment_ids, name=None)
Computes the sum along sparse segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Like SegmentSum
, but segment_ids
can have rank less than data
's first
dimension, selecting a subset of dimension 0, specified by indices
.
For example:
```prettyprint c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
Select two rows, one segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0])) ==> [[0 0 0 0]]
Select two rows, two segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1])) ==> [[ 1 2 3 4] [-1 -2 -3 -4]]
Select all rows, two segments.
tf.sparse_segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1])) ==> [[0 0 0 0] [5 6 7 8]]
Which is equivalent to:
tf.segment_sum(c, tf.constant([0, 0, 1])) ```
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_segment_sum_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_segment_sum_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_segment_sum_layer
Return
Applicative
Origial documentation for Builder.sparse_segment_sum_layer
def sparse_segment_sum_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_segment_sum, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.sparse_segment_sum
def sparse_segment_sum(data, indices, segment_ids, name=None):
Computes the sum along sparse segments of a tensor.
Read the section on Segmentation for an explanation of segments.
Like SegmentSum
, but segment_ids
can have rank less than data
's first
dimension, selecting a subset of dimension 0, specified by indices
.
For example:
```prettyprint c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
Select two rows, one segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0])) ==> [[0 0 0 0]]
Select two rows, two segment.
tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1])) ==> [[ 1 2 3 4] [-1 -2 -3 -4]]
Select all rows, two segments.
tf.sparse_segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1])) ==> [[0 0 0 0] [5 6 7 8]]
Which is equivalent to:
tf.segment_sum(c, tf.constant([0, 0, 1])) ```
Args:
data: A Tensor
. Must be one of the following types: float32
, float64
, int32
, int64
, uint8
, int16
, int8
, uint16
, half
.
indices: A Tensor
. Must be one of the following types: int32
, int64
.
A 1-D tensor. Has same rank as segment_ids
.
segment_ids: A Tensor
of type int32
.
A 1-D tensor. 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 sparse_softmax(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_softmax, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_softmax
Return
Applicative
Origial documentation for Builder.sparse_softmax
def sparse_softmax(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_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.sparse_softmax
def sparse_softmax(sp_input, name=None)
Applies softmax to a batched N-D SparseTensor
.
The inputs represent an N-D SparseTensor with logical shape [..., B, C]
(where N >= 2
), and with indices sorted in the canonical lexicographic
order.
This op is equivalent to applying the normal tf.nn.softmax()
to each
innermost logical submatrix with shape [B, C]
, but with the catch that the
implicitly zero elements do not participate. Specifically, the algorithm is
equivalent to:
(1) Applies tf.nn.softmax()
to a densified view of each innermost
submatrix with shape [B, C]
, along the size-C dimension;
(2) Masks out the original implicitly-zero locations;
(3) Renormalizes the remaining elements.
Hence, the SparseTensor
result has exactly the same non-zero indices and
shape.
Example:
```python
First batch:
[? e.]
[1. ? ]
Second batch:
[e ? ]
[e e ]
shape = [2, 2, 2] # 3-D SparseTensor values = np.asarray([[[0., np.e], [1., 0.]], [[np.e, 0.], [np.e, np.e]]]) indices = np.vstack(np.where(values)).astype(np.int64).T
result = tf.sparse_softmax(tf.SparseTensor(indices, values, shape))
...returning a 3-D SparseTensor, equivalent to:
[? 1.] [1 ?]
[1. ? ] and [.5 .5]
where ? means implicitly zero.
```
Args:
sp_input: N-D SparseTensor
, where N >= 2
.
name: optional name of the operation.
Returns:
output: N-D SparseTensor
representing the results.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_softmax_cross_entropy_with_logits(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_softmax_cross_entropy_with_logits, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_softmax_cross_entropy_with_logits
Return
Applicative
Origial documentation for Builder.sparse_softmax_cross_entropy_with_logits
def sparse_softmax_cross_entropy_with_logits(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.sparse_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.sparse_softmax_cross_entropy_with_logits
def sparse_softmax_cross_entropy_with_logits(logits, labels, name=None)
Computes sparse 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: For this operation, the probability of a given label is considered
exclusive. That is, soft classes are not allowed, and the labels
vector
must provide a single specific index for the true class for each row of
logits
(each minibatch entry). For soft softmax classification with
a probability distribution for each entry, see
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.
A common use case is to have logits of shape [batch_size, num_classes]
and
labels of shape [batch_size]
. But higher dimensions are supported.
Args:
logits: Unscaled log probabilities of rank r
and shape
[d_0, d_1, ..., d_{r-2}, num_classes]
and dtype float32
or float64
.
labels: Tensor
of shape [d_0, d_1, ..., d_{r-2}]
and dtype int32
or
int64
. Each entry in labels
must be an index in [0, num_classes)
.
Other values will raise an exception when this op is run on CPU, and
return NaN
for corresponding corresponding loss and gradient rows
on GPU.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as labels
and of the same type as logits
with the softmax cross entropy loss.
Raises: ValueError: If logits are scalars (need to have rank >= 1) or if the rank of the labels is not equal to the rank of the labels minus one.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_softmax_cross_entropy_with_logits_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_softmax_cross_entropy_with_logits_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_softmax_cross_entropy_with_logits_layer
Return
Applicative
Origial documentation for Builder.sparse_softmax_cross_entropy_with_logits_layer
def sparse_softmax_cross_entropy_with_logits_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.sparse_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.sparse_softmax_cross_entropy_with_logits
def sparse_softmax_cross_entropy_with_logits(logits, labels, name=None):
Computes sparse 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: For this operation, the probability of a given label is considered
exclusive. That is, soft classes are not allowed, and the labels
vector
must provide a single specific index for the true class for each row of
logits
(each minibatch entry). For soft softmax classification with
a probability distribution for each entry, see
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.
A common use case is to have logits of shape [batch_size, num_classes]
and
labels of shape [batch_size]
. But higher dimensions are supported.
Args:
logits: Unscaled log probabilities of rank r
and shape
[d_0, d_1, ..., d_{r-2}, num_classes]
and dtype float32
or float64
.
labels: Tensor
of shape [d_0, d_1, ..., d_{r-2}]
and dtype int32
or
int64
. Each entry in labels
must be an index in [0, num_classes)
.
Other values will raise an exception when this op is run on CPU, and
return NaN
for corresponding corresponding loss and gradient rows
on GPU.
name: A name for the operation (optional).
Returns:
A Tensor
of the same shape as labels
and of the same type as logits
with the softmax cross entropy loss.
Raises: ValueError: If logits are scalars (need to have rank >= 1) or if the rank of the labels is not equal to the rank of the labels minus one.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_softmax_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_softmax_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_softmax_layer
Return
Applicative
Origial documentation for Builder.sparse_softmax_layer
def sparse_softmax_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_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.sparse_softmax
def sparse_softmax(sp_input, name=None):
Applies softmax to a batched N-D SparseTensor
.
The inputs represent an N-D SparseTensor with logical shape [..., B, C]
(where N >= 2
), and with indices sorted in the canonical lexicographic
order.
This op is equivalent to applying the normal tf.nn.softmax()
to each
innermost logical submatrix with shape [B, C]
, but with the catch that the
implicitly zero elements do not participate. Specifically, the algorithm is
equivalent to:
(1) Applies tf.nn.softmax()
to a densified view of each innermost
submatrix with shape [B, C]
, along the size-C dimension;
(2) Masks out the original implicitly-zero locations;
(3) Renormalizes the remaining elements.
Hence, the SparseTensor
result has exactly the same non-zero indices and
shape.
Example:
```python
First batch:
[? e.]
[1. ? ]
Second batch:
[e ? ]
[e e ]
shape = [2, 2, 2] # 3-D SparseTensor values = np.asarray([[[0., np.e], [1., 0.]], [[np.e, 0.], [np.e, np.e]]]) indices = np.vstack(np.where(values)).astype(np.int64).T
result = tf.sparse_softmax(tf.SparseTensor(indices, values, shape))
...returning a 3-D SparseTensor, equivalent to:
[? 1.] [1 ?]
[1. ? ] and [.5 .5]
where ? means implicitly zero.
```
Args:
sp_input: N-D SparseTensor
, where N >= 2
.
name: optional name of the operation.
Returns:
output: N-D SparseTensor
representing the results.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_split(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_split, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_split
Return
Applicative
Origial documentation for Builder.sparse_split
def sparse_split(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_split
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_split
def sparse_split(split_dim, num_split, sp_input, name=None)
Split a SparseTensor
into num_split
tensors along split_dim
.
If the sp_input.shape[split_dim]
is not an integer multiple of num_split
each slice starting from 0:shape[split_dim] % num_split
gets extra one
dimension. For example, if split_dim = 1
and num_split = 2
and the
input is:
input_tensor = shape = [2, 7] [ a d e ] [b c ]
Graphically the output tensors are:
output_tensor[0] = [ a ] [b c ] output_tensor[1] = [ d e ] [ ]
Args:
split_dim: A 0-D int32
Tensor
. The dimension along which to split.
num_split: A Python integer. The number of ways to split.
sp_input: The SparseTensor
to split.
name: A name for the operation (optional).
Returns:
num_split
SparseTensor
objects resulting from splitting value
.
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_split_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_split_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_split_layer
Return
Applicative
Origial documentation for Builder.sparse_split_layer
def sparse_split_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_split, ...)
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_split
def sparse_split(split_dim, num_split, sp_input, name=None):
Split a SparseTensor
into num_split
tensors along split_dim
.
If the sp_input.shape[split_dim]
is not an integer multiple of num_split
each slice starting from 0:shape[split_dim] % num_split
gets extra one
dimension. For example, if split_dim = 1
and num_split = 2
and the
input is:
input_tensor = shape = [2, 7] [ a d e ] [b c ]
Graphically the output tensors are:
output_tensor[0] = [ a ] [b c ] output_tensor[1] = [ d e ] [ ]
Args:
split_dim: A 0-D int32
Tensor
. The dimension along which to split.
num_split: A Python integer. The number of ways to split.
sp_input: The SparseTensor
to split.
name: A name for the operation (optional).
Returns:
num_split
SparseTensor
objects resulting from splitting value
.
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_tensor_dense_matmul(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_tensor_dense_matmul, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_tensor_dense_matmul
Return
Applicative
Origial documentation for Builder.sparse_tensor_dense_matmul
def sparse_tensor_dense_matmul(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_tensor_dense_matmul
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_tensor_dense_matmul
def sparse_tensor_dense_matmul(sp_a, b, adjoint_a=False, adjoint_b=False, name=None)
Multiply SparseTensor (of rank 2) "A" by dense matrix "B".
No validity checking is performed on the indices of A. However, the following input format is recommended for optimal behavior:
if adjoint_a == false: A should be sorted in lexicographically increasing order. Use sparse_reorder if you're not sure. if adjoint_a == true: A should be sorted in order of increasing dimension 1 (i.e., "column major" order instead of "row major" order).
Deciding when to use sparse_tensor_dense_matmul vs. matmul(sp_a=True):
There are a number of questions to ask in the decision process, including:
- Will the SparseTensor A fit in memory if densified?
- Is the column count of the product large (>> 1)?
- Is the density of A larger than approximately 15%?
If the answer to several of these questions is yes, consider converting the SparseTensor to a dense one and using tf.matmul with sp_a=True.
This operation tends to perform well when A is more sparse, if the column size of the product is small (e.g. matrix-vector multiplication), if sp_a.shape takes on large values.
Below is a rough speed comparison between sparse_tensor_dense_matmul, labelled 'sparse', and matmul(sp_a=True), labelled 'dense'. For purposes of the comparison, the time spent converting from a SparseTensor to a dense Tensor is not included, so it is overly conservative with respect to the time ratio.
Benchmark system: CPU: Intel Ivybridge with HyperThreading (6 cores) dL1:32KB dL2:256KB dL3:12MB GPU: NVidia Tesla k40c
Compiled with: -c opt --config=cuda --copt=-mavx
```tensorflow/python/sparse_tensor_dense_matmul_op_test --benchmarks A sparse [m, k] with % nonzero values between 1% and 80% B dense [k, n]
% nnz n gpu m k dt(dense) dt(sparse) dt(sparse)/dt(dense) 0.01 1 True 100 100 0.000221166 0.00010154 0.459112 0.01 1 True 100 1000 0.00033858 0.000109275 0.322745 0.01 1 True 1000 100 0.000310557 9.85661e-05 0.317385 0.01 1 True 1000 1000 0.0008721 0.000100875 0.115669 0.01 1 False 100 100 0.000208085 0.000107603 0.51711 0.01 1 False 100 1000 0.000327112 9.51118e-05 0.290762 0.01 1 False 1000 100 0.000308222 0.00010345 0.335635 0.01 1 False 1000 1000 0.000865721 0.000101397 0.117124 0.01 10 True 100 100 0.000218522 0.000105537 0.482958 0.01 10 True 100 1000 0.000340882 0.000111641 0.327506 0.01 10 True 1000 100 0.000315472 0.000117376 0.372064 0.01 10 True 1000 1000 0.000905493 0.000123263 0.136128 0.01 10 False 100 100 0.000221529 9.82571e-05 0.44354 0.01 10 False 100 1000 0.000330552 0.000112615 0.340687 0.01 10 False 1000 100 0.000341277 0.000114097 0.334324 0.01 10 False 1000 1000 0.000819944 0.000120982 0.147549 0.01 25 True 100 100 0.000207806 0.000105977 0.509981 0.01 25 True 100 1000 0.000322879 0.00012921 0.400181 0.01 25 True 1000 100 0.00038262 0.000141583 0.370035 0.01 25 True 1000 1000 0.000865438 0.000202083 0.233504 0.01 25 False 100 100 0.000209401 0.000104696 0.499979 0.01 25 False 100 1000 0.000321161 0.000130737 0.407076 0.01 25 False 1000 100 0.000377012 0.000136801 0.362856 0.01 25 False 1000 1000 0.000861125 0.00020272 0.235413 0.2 1 True 100 100 0.000206952 9.69219e-05 0.46833 0.2 1 True 100 1000 0.000348674 0.000147475 0.422959 0.2 1 True 1000 100 0.000336908 0.00010122 0.300439 0.2 1 True 1000 1000 0.001022 0.000203274 0.198898 0.2 1 False 100 100 0.000207532 9.5412e-05 0.459746 0.2 1 False 100 1000 0.000356127 0.000146824 0.41228 0.2 1 False 1000 100 0.000322664 0.000100918 0.312764 0.2 1 False 1000 1000 0.000998987 0.000203442 0.203648 0.2 10 True 100 100 0.000211692 0.000109903 0.519165 0.2 10 True 100 1000 0.000372819 0.000164321 0.440753 0.2 10 True 1000 100 0.000338651 0.000144806 0.427596 0.2 10 True 1000 1000 0.00108312 0.000758876 0.70064 0.2 10 False 100 100 0.000215727 0.000110502 0.512231 0.2 10 False 100 1000 0.000375419 0.0001613 0.429653 0.2 10 False 1000 100 0.000336999 0.000145628 0.432132 0.2 10 False 1000 1000 0.00110502 0.000762043 0.689618 0.2 25 True 100 100 0.000218705 0.000129913 0.594009 0.2 25 True 100 1000 0.000394794 0.00029428 0.745402 0.2 25 True 1000 100 0.000404483 0.0002693 0.665788 0.2 25 True 1000 1000 0.0012002 0.00194494 1.62052 0.2 25 False 100 100 0.000221494 0.0001306 0.589632 0.2 25 False 100 1000 0.000396436 0.000297204 0.74969 0.2 25 False 1000 100 0.000409346 0.000270068 0.659754 0.2 25 False 1000 1000 0.00121051 0.00193737 1.60046 0.5 1 True 100 100 0.000214981 9.82111e-05 0.456836 0.5 1 True 100 1000 0.000415328 0.000223073 0.537101 0.5 1 True 1000 100 0.000358324 0.00011269 0.314492 0.5 1 True 1000 1000 0.00137612 0.000437401 0.317851 0.5 1 False 100 100 0.000224196 0.000101423 0.452386 0.5 1 False 100 1000 0.000400987 0.000223286 0.556841 0.5 1 False 1000 100 0.000368825 0.00011224 0.304318 0.5 1 False 1000 1000 0.00136036 0.000429369 0.31563 0.5 10 True 100 100 0.000222125 0.000112308 0.505608 0.5 10 True 100 1000 0.000461088 0.00032357 0.701753 0.5 10 True 1000 100 0.000394624 0.000225497 0.571422 0.5 10 True 1000 1000 0.00158027 0.00190898 1.20801 0.5 10 False 100 100 0.000232083 0.000114978 0.495418 0.5 10 False 100 1000 0.000454574 0.000324632 0.714146 0.5 10 False 1000 100 0.000379097 0.000227768 0.600817 0.5 10 False 1000 1000 0.00160292 0.00190168 1.18638 0.5 25 True 100 100 0.00023429 0.000151703 0.647501 0.5 25 True 100 1000 0.000497462 0.000598873 1.20386 0.5 25 True 1000 100 0.000460778 0.000557038 1.20891 0.5 25 True 1000 1000 0.00170036 0.00467336 2.74845 0.5 25 False 100 100 0.000228981 0.000155334 0.678371 0.5 25 False 100 1000 0.000496139 0.000620789 1.25124 0.5 25 False 1000 100 0.00045473 0.000551528 1.21287 0.5 25 False 1000 1000 0.00171793 0.00467152 2.71927 0.8 1 True 100 100 0.000222037 0.000105301 0.47425 0.8 1 True 100 1000 0.000410804 0.000329327 0.801664 0.8 1 True 1000 100 0.000349735 0.000131225 0.375212 0.8 1 True 1000 1000 0.00139219 0.000677065 0.48633 0.8 1 False 100 100 0.000214079 0.000107486 0.502085 0.8 1 False 100 1000 0.000413746 0.000323244 0.781261 0.8 1 False 1000 100 0.000348983 0.000131983 0.378193 0.8 1 False 1000 1000 0.00136296 0.000685325 0.50282 0.8 10 True 100 100 0.000229159 0.00011825 0.516017 0.8 10 True 100 1000 0.000498845 0.000532618 1.0677 0.8 10 True 1000 100 0.000383126 0.00029935 0.781336 0.8 10 True 1000 1000 0.00162866 0.00307312 1.88689 0.8 10 False 100 100 0.000230783 0.000124958 0.541452 0.8 10 False 100 1000 0.000493393 0.000550654 1.11606 0.8 10 False 1000 100 0.000377167 0.000298581 0.791642 0.8 10 False 1000 1000 0.00165795 0.00305103 1.84024 0.8 25 True 100 100 0.000233496 0.000175241 0.75051 0.8 25 True 100 1000 0.00055654 0.00102658 1.84458 0.8 25 True 1000 100 0.000463814 0.000783267 1.68875 0.8 25 True 1000 1000 0.00186905 0.00755344 4.04132 0.8 25 False 100 100 0.000240243 0.000175047 0.728625 0.8 25 False 100 1000 0.000578102 0.00104499 1.80763 0.8 25 False 1000 100 0.000485113 0.000776849 1.60138 0.8 25 False 1000 1000 0.00211448 0.00752736 3.55992 ```
Args: sp_a: SparseTensor A, of rank 2. b: A dense Matrix with the same dtype as sp_a. adjoint_a: Use the adjoint of A in the matrix multiply. If A is complex, this is transpose(conj(A)). Otherwise it's transpose(A). adjoint_b: Use the adjoint of B in the matrix multiply. If B is complex, this is transpose(conj(B)). Otherwise it's transpose(B). name: A name prefix for the returned tensors (optional)
Returns: A dense matrix (pseudo-code in dense np.matrix notation): A = A.H if adjoint_a else A B = B.H if adjoint_b else B return A*B
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_tensor_dense_matmul_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_tensor_dense_matmul_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_tensor_dense_matmul_layer
Return
Applicative
Origial documentation for Builder.sparse_tensor_dense_matmul_layer
def sparse_tensor_dense_matmul_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_tensor_dense_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_tensor_dense_matmul
def sparse_tensor_dense_matmul(sp_a, b, adjoint_a=False, adjoint_b=False, name=None):
Multiply SparseTensor (of rank 2) "A" by dense matrix "B".
No validity checking is performed on the indices of A. However, the following input format is recommended for optimal behavior:
if adjoint_a == false: A should be sorted in lexicographically increasing order. Use sparse_reorder if you're not sure. if adjoint_a == true: A should be sorted in order of increasing dimension 1 (i.e., "column major" order instead of "row major" order).
Deciding when to use sparse_tensor_dense_matmul vs. matmul(sp_a=True):
There are a number of questions to ask in the decision process, including:
- Will the SparseTensor A fit in memory if densified?
- Is the column count of the product large (>> 1)?
- Is the density of A larger than approximately 15%?
If the answer to several of these questions is yes, consider converting the SparseTensor to a dense one and using tf.matmul with sp_a=True.
This operation tends to perform well when A is more sparse, if the column size of the product is small (e.g. matrix-vector multiplication), if sp_a.shape takes on large values.
Below is a rough speed comparison between sparse_tensor_dense_matmul, labelled 'sparse', and matmul(sp_a=True), labelled 'dense'. For purposes of the comparison, the time spent converting from a SparseTensor to a dense Tensor is not included, so it is overly conservative with respect to the time ratio.
Benchmark system: CPU: Intel Ivybridge with HyperThreading (6 cores) dL1:32KB dL2:256KB dL3:12MB GPU: NVidia Tesla k40c
Compiled with: -c opt --config=cuda --copt=-mavx
```tensorflow/python/sparse_tensor_dense_matmul_op_test --benchmarks A sparse [m, k] with % nonzero values between 1% and 80% B dense [k, n]
% nnz n gpu m k dt(dense) dt(sparse) dt(sparse)/dt(dense) 0.01 1 True 100 100 0.000221166 0.00010154 0.459112 0.01 1 True 100 1000 0.00033858 0.000109275 0.322745 0.01 1 True 1000 100 0.000310557 9.85661e-05 0.317385 0.01 1 True 1000 1000 0.0008721 0.000100875 0.115669 0.01 1 False 100 100 0.000208085 0.000107603 0.51711 0.01 1 False 100 1000 0.000327112 9.51118e-05 0.290762 0.01 1 False 1000 100 0.000308222 0.00010345 0.335635 0.01 1 False 1000 1000 0.000865721 0.000101397 0.117124 0.01 10 True 100 100 0.000218522 0.000105537 0.482958 0.01 10 True 100 1000 0.000340882 0.000111641 0.327506 0.01 10 True 1000 100 0.000315472 0.000117376 0.372064 0.01 10 True 1000 1000 0.000905493 0.000123263 0.136128 0.01 10 False 100 100 0.000221529 9.82571e-05 0.44354 0.01 10 False 100 1000 0.000330552 0.000112615 0.340687 0.01 10 False 1000 100 0.000341277 0.000114097 0.334324 0.01 10 False 1000 1000 0.000819944 0.000120982 0.147549 0.01 25 True 100 100 0.000207806 0.000105977 0.509981 0.01 25 True 100 1000 0.000322879 0.00012921 0.400181 0.01 25 True 1000 100 0.00038262 0.000141583 0.370035 0.01 25 True 1000 1000 0.000865438 0.000202083 0.233504 0.01 25 False 100 100 0.000209401 0.000104696 0.499979 0.01 25 False 100 1000 0.000321161 0.000130737 0.407076 0.01 25 False 1000 100 0.000377012 0.000136801 0.362856 0.01 25 False 1000 1000 0.000861125 0.00020272 0.235413 0.2 1 True 100 100 0.000206952 9.69219e-05 0.46833 0.2 1 True 100 1000 0.000348674 0.000147475 0.422959 0.2 1 True 1000 100 0.000336908 0.00010122 0.300439 0.2 1 True 1000 1000 0.001022 0.000203274 0.198898 0.2 1 False 100 100 0.000207532 9.5412e-05 0.459746 0.2 1 False 100 1000 0.000356127 0.000146824 0.41228 0.2 1 False 1000 100 0.000322664 0.000100918 0.312764 0.2 1 False 1000 1000 0.000998987 0.000203442 0.203648 0.2 10 True 100 100 0.000211692 0.000109903 0.519165 0.2 10 True 100 1000 0.000372819 0.000164321 0.440753 0.2 10 True 1000 100 0.000338651 0.000144806 0.427596 0.2 10 True 1000 1000 0.00108312 0.000758876 0.70064 0.2 10 False 100 100 0.000215727 0.000110502 0.512231 0.2 10 False 100 1000 0.000375419 0.0001613 0.429653 0.2 10 False 1000 100 0.000336999 0.000145628 0.432132 0.2 10 False 1000 1000 0.00110502 0.000762043 0.689618 0.2 25 True 100 100 0.000218705 0.000129913 0.594009 0.2 25 True 100 1000 0.000394794 0.00029428 0.745402 0.2 25 True 1000 100 0.000404483 0.0002693 0.665788 0.2 25 True 1000 1000 0.0012002 0.00194494 1.62052 0.2 25 False 100 100 0.000221494 0.0001306 0.589632 0.2 25 False 100 1000 0.000396436 0.000297204 0.74969 0.2 25 False 1000 100 0.000409346 0.000270068 0.659754 0.2 25 False 1000 1000 0.00121051 0.00193737 1.60046 0.5 1 True 100 100 0.000214981 9.82111e-05 0.456836 0.5 1 True 100 1000 0.000415328 0.000223073 0.537101 0.5 1 True 1000 100 0.000358324 0.00011269 0.314492 0.5 1 True 1000 1000 0.00137612 0.000437401 0.317851 0.5 1 False 100 100 0.000224196 0.000101423 0.452386 0.5 1 False 100 1000 0.000400987 0.000223286 0.556841 0.5 1 False 1000 100 0.000368825 0.00011224 0.304318 0.5 1 False 1000 1000 0.00136036 0.000429369 0.31563 0.5 10 True 100 100 0.000222125 0.000112308 0.505608 0.5 10 True 100 1000 0.000461088 0.00032357 0.701753 0.5 10 True 1000 100 0.000394624 0.000225497 0.571422 0.5 10 True 1000 1000 0.00158027 0.00190898 1.20801 0.5 10 False 100 100 0.000232083 0.000114978 0.495418 0.5 10 False 100 1000 0.000454574 0.000324632 0.714146 0.5 10 False 1000 100 0.000379097 0.000227768 0.600817 0.5 10 False 1000 1000 0.00160292 0.00190168 1.18638 0.5 25 True 100 100 0.00023429 0.000151703 0.647501 0.5 25 True 100 1000 0.000497462 0.000598873 1.20386 0.5 25 True 1000 100 0.000460778 0.000557038 1.20891 0.5 25 True 1000 1000 0.00170036 0.00467336 2.74845 0.5 25 False 100 100 0.000228981 0.000155334 0.678371 0.5 25 False 100 1000 0.000496139 0.000620789 1.25124 0.5 25 False 1000 100 0.00045473 0.000551528 1.21287 0.5 25 False 1000 1000 0.00171793 0.00467152 2.71927 0.8 1 True 100 100 0.000222037 0.000105301 0.47425 0.8 1 True 100 1000 0.000410804 0.000329327 0.801664 0.8 1 True 1000 100 0.000349735 0.000131225 0.375212 0.8 1 True 1000 1000 0.00139219 0.000677065 0.48633 0.8 1 False 100 100 0.000214079 0.000107486 0.502085 0.8 1 False 100 1000 0.000413746 0.000323244 0.781261 0.8 1 False 1000 100 0.000348983 0.000131983 0.378193 0.8 1 False 1000 1000 0.00136296 0.000685325 0.50282 0.8 10 True 100 100 0.000229159 0.00011825 0.516017 0.8 10 True 100 1000 0.000498845 0.000532618 1.0677 0.8 10 True 1000 100 0.000383126 0.00029935 0.781336 0.8 10 True 1000 1000 0.00162866 0.00307312 1.88689 0.8 10 False 100 100 0.000230783 0.000124958 0.541452 0.8 10 False 100 1000 0.000493393 0.000550654 1.11606 0.8 10 False 1000 100 0.000377167 0.000298581 0.791642 0.8 10 False 1000 1000 0.00165795 0.00305103 1.84024 0.8 25 True 100 100 0.000233496 0.000175241 0.75051 0.8 25 True 100 1000 0.00055654 0.00102658 1.84458 0.8 25 True 1000 100 0.000463814 0.000783267 1.68875 0.8 25 True 1000 1000 0.00186905 0.00755344 4.04132 0.8 25 False 100 100 0.000240243 0.000175047 0.728625 0.8 25 False 100 1000 0.000578102 0.00104499 1.80763 0.8 25 False 1000 100 0.000485113 0.000776849 1.60138 0.8 25 False 1000 1000 0.00211448 0.00752736 3.55992 ```
Args: sp_a: SparseTensor A, of rank 2. b: A dense Matrix with the same dtype as sp_a. adjoint_a: Use the adjoint of A in the matrix multiply. If A is complex, this is transpose(conj(A)). Otherwise it's transpose(A). adjoint_b: Use the adjoint of B in the matrix multiply. If B is complex, this is transpose(conj(B)). Otherwise it's transpose(B). name: A name prefix for the returned tensors (optional)
Returns: A dense matrix (pseudo-code in dense np.matrix notation): A = A.H if adjoint_a else A B = B.H if adjoint_b else B return A*B
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_tensor_to_dense(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_tensor_to_dense, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_tensor_to_dense
Return
Applicative
Origial documentation for Builder.sparse_tensor_to_dense
def sparse_tensor_to_dense(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_tensor_to_dense
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_tensor_to_dense
def sparse_tensor_to_dense(sp_input, default_value=0, validate_indices=True, name=None)
Converts a SparseTensor
into a dense tensor.
This op is a convenience wrapper around sparse_to_dense
for SparseTensor
s.
For example, if sp_input
has shape [3, 5]
and non-empty string values:
[0, 1]: a [0, 3]: b [2, 0]: c
and default_value
is x
, then the output will be a dense [3, 5]
string tensor with values:
[[x a x b x] [x x x x x] [c x x x x]]
Indices must be without repeats. This is only tested if validate_indices is True.
Args:
sp_input: The input SparseTensor
.
default_value: Scalar value to set for indices not specified in
sp_input
. Defaults to zero.
validate_indices: A boolean value. If True
, indices are checked to make
sure they are sorted in lexicographic order and that there are no repeats.
name: A name prefix for the returned tensors (optional).
Returns:
A dense tensor with shape sp_input.shape
and values specified by
the non-empty values in sp_input
. Indices not in sp_input
are assigned
default_value
.
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_tensor_to_dense_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_tensor_to_dense_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_tensor_to_dense_layer
Return
Applicative
Origial documentation for Builder.sparse_tensor_to_dense_layer
def sparse_tensor_to_dense_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_tensor_to_dense, ...)
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_tensor_to_dense
def sparse_tensor_to_dense(sp_input, default_value=0, validate_indices=True, name=None):
Converts a SparseTensor
into a dense tensor.
This op is a convenience wrapper around sparse_to_dense
for SparseTensor
s.
For example, if sp_input
has shape [3, 5]
and non-empty string values:
[0, 1]: a [0, 3]: b [2, 0]: c
and default_value
is x
, then the output will be a dense [3, 5]
string tensor with values:
[[x a x b x] [x x x x x] [c x x x x]]
Indices must be without repeats. This is only tested if validate_indices is True.
Args:
sp_input: The input SparseTensor
.
default_value: Scalar value to set for indices not specified in
sp_input
. Defaults to zero.
validate_indices: A boolean value. If True
, indices are checked to make
sure they are sorted in lexicographic order and that there are no repeats.
name: A name prefix for the returned tensors (optional).
Returns:
A dense tensor with shape sp_input.shape
and values specified by
the non-empty values in sp_input
. Indices not in sp_input
are assigned
default_value
.
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_to_dense(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_to_dense, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_to_dense
Return
Applicative
Origial documentation for Builder.sparse_to_dense
def sparse_to_dense(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_to_dense
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_to_dense
def sparse_to_dense(sparse_indices, output_shape, sparse_values, default_value=0, validate_indices=True, name=None)
Converts a sparse representation into a dense tensor.
Builds an array dense
with shape output_shape
such that
```python
If sparse_indices is scalar
dense[i] = (i == sparse_indices ? sparse_values : default_value)
If sparse_indices is a vector, then for each i
dense[sparse_indices[i]] = sparse_values[i]
If sparse_indices is an n by d matrix, then for each i in [0, n)
dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = sparse_values[i] ```
All other values in dense
are set to default_value
. If sparse_values
is a scalar, all sparse indices are set to this single value.
Indices should be sorted in lexicographic order, and indices must not
contain any repeats. If validate_indices
is True, these properties
are checked during execution.
Args:
sparse_indices: A 0-D, 1-D, or 2-D Tensor
of type int32
or int64
.
sparse_indices[i]
contains the complete index where sparse_values[i]
will be placed.
output_shape: A 1-D Tensor
of the same type as sparse_indices
. Shape
of the dense output tensor.
sparse_values: A 0-D or 1-D Tensor
. Values corresponding to each row of
sparse_indices
, or a scalar value to be used for all sparse indices.
default_value: A 0-D Tensor
of the same type as sparse_values
. Value
to set for indices not specified in sparse_indices
. Defaults to zero.
validate_indices: A boolean value. If True, indices are checked to make
sure they are sorted in lexicographic order and that there are no repeats.
name: A name for the operation (optional).
Returns:
Dense Tensor
of shape output_shape
. Has the same type as
sparse_values
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_to_dense_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_to_dense_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_to_dense_layer
Return
Applicative
Origial documentation for Builder.sparse_to_dense_layer
def sparse_to_dense_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_to_dense, ...)
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_to_dense
def sparse_to_dense(sparse_indices, output_shape, sparse_values, default_value=0, validate_indices=True, name=None):
Converts a sparse representation into a dense tensor.
Builds an array dense
with shape output_shape
such that
```python
If sparse_indices is scalar
dense[i] = (i == sparse_indices ? sparse_values : default_value)
If sparse_indices is a vector, then for each i
dense[sparse_indices[i]] = sparse_values[i]
If sparse_indices is an n by d matrix, then for each i in [0, n)
dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = sparse_values[i] ```
All other values in dense
are set to default_value
. If sparse_values
is a scalar, all sparse indices are set to this single value.
Indices should be sorted in lexicographic order, and indices must not
contain any repeats. If validate_indices
is True, these properties
are checked during execution.
Args:
sparse_indices: A 0-D, 1-D, or 2-D Tensor
of type int32
or int64
.
sparse_indices[i]
contains the complete index where sparse_values[i]
will be placed.
output_shape: A 1-D Tensor
of the same type as sparse_indices
. Shape
of the dense output tensor.
sparse_values: A 0-D or 1-D Tensor
. Values corresponding to each row of
sparse_indices
, or a scalar value to be used for all sparse indices.
default_value: A 0-D Tensor
of the same type as sparse_values
. Value
to set for indices not specified in sparse_indices
. Defaults to zero.
validate_indices: A boolean value. If True, indices are checked to make
sure they are sorted in lexicographic order and that there are no repeats.
name: A name for the operation (optional).
Returns:
Dense Tensor
of shape output_shape
. Has the same type as
sparse_values
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sparse_to_indicator(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_to_indicator, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_to_indicator
Return
Applicative
Origial documentation for Builder.sparse_to_indicator
def sparse_to_indicator(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_to_indicator
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_to_indicator
def sparse_to_indicator(sp_input, vocab_size, name=None)
Converts a SparseTensor
of ids into a dense bool indicator tensor.
The last dimension of sp_input.indices
is discarded and replaced with
the values of sp_input
. If sp_input.shape = [D0, D1, ..., Dn, K]
, then
output.shape = [D0, D1, ..., Dn, vocab_size]
, where
output[d_0, d_1, ..., d_n, sp_input[d_0, d_1, ..., d_n, k]] = True
and False elsewhere in output
.
For example, if sp_input.shape = [2, 3, 4]
with non-empty values:
[0, 0, 0]: 0 [0, 1, 0]: 10 [1, 0, 3]: 103 [1, 1, 2]: 150 [1, 1, 3]: 149 [1, 1, 4]: 150 [1, 2, 1]: 121
and vocab_size = 200
, then the output will be a [2, 3, 200]
dense bool
tensor with False everywhere except at positions
(0, 0, 0), (0, 1, 10), (1, 0, 103), (1, 1, 149), (1, 1, 150), (1, 2, 121).
Note that repeats are allowed in the input SparseTensor.
This op is useful for converting SparseTensor
s into dense formats for
compatibility with ops that expect dense tensors.
The input SparseTensor
must be in row-major order.
Args:
sp_input: A SparseTensor
with values
property of type int32
or
int64
.
vocab_size: A scalar int64 Tensor (or Python int) containing the new size
of the last dimension, all(0 <= sp_input.values < vocab_size)
.
name: A name prefix for the returned tensors (optional)
Returns: A dense bool indicator tensor representing the indices with specified value.
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_to_indicator_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_to_indicator_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_to_indicator_layer
Return
Applicative
Origial documentation for Builder.sparse_to_indicator_layer
def sparse_to_indicator_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_to_indicator, ...)
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_to_indicator
def sparse_to_indicator(sp_input, vocab_size, name=None):
Converts a SparseTensor
of ids into a dense bool indicator tensor.
The last dimension of sp_input.indices
is discarded and replaced with
the values of sp_input
. If sp_input.shape = [D0, D1, ..., Dn, K]
, then
output.shape = [D0, D1, ..., Dn, vocab_size]
, where
output[d_0, d_1, ..., d_n, sp_input[d_0, d_1, ..., d_n, k]] = True
and False elsewhere in output
.
For example, if sp_input.shape = [2, 3, 4]
with non-empty values:
[0, 0, 0]: 0 [0, 1, 0]: 10 [1, 0, 3]: 103 [1, 1, 2]: 150 [1, 1, 3]: 149 [1, 1, 4]: 150 [1, 2, 1]: 121
and vocab_size = 200
, then the output will be a [2, 3, 200]
dense bool
tensor with False everywhere except at positions
(0, 0, 0), (0, 1, 10), (1, 0, 103), (1, 1, 149), (1, 1, 150), (1, 2, 121).
Note that repeats are allowed in the input SparseTensor.
This op is useful for converting SparseTensor
s into dense formats for
compatibility with ops that expect dense tensors.
The input SparseTensor
must be in row-major order.
Args:
sp_input: A SparseTensor
with values
property of type int32
or
int64
.
vocab_size: A scalar int64 Tensor (or Python int) containing the new size
of the last dimension, all(0 <= sp_input.values < vocab_size)
.
name: A name prefix for the returned tensors (optional)
Returns: A dense bool indicator tensor representing the indices with specified value.
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_transpose(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_transpose, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_transpose
Return
Applicative
Origial documentation for Builder.sparse_transpose
def sparse_transpose(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sparse_transpose
to work with tensorbuilder.core.builders.Builder
s. Instead of taking a Tensor as its first argument it takes a builder, the rest of the arguments are exactly the same.
Original Documentation for tf.sparse_transpose
def sparse_transpose(sp_input, perm=None, name=None)
Transposes a SparseTensor
The returned tensor's dimension i will correspond to the input dimension
perm[i]
. If perm
is not given, it is set to (n-1...0), where n is
the rank of the input tensor. Hence by default, this operation performs a
regular matrix transpose on 2-D input Tensors.
For example, if sp_input
has shape [4, 5]
and indices
/ values
:
[0, 3]: b [0, 1]: a [3, 1]: d [2, 0]: c
then the output will be a SparseTensor
of shape [5, 4]
and
indices
/ values
:
[0, 2]: c [1, 0]: a [1, 3]: d [3, 0]: b
Args:
sp_input: The input SparseTensor
.
perm: A permutation of the dimensions of sp_input
.
name: A name prefix for the returned tensors (optional)
Returns:
A transposed SparseTensor
.
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_transpose_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sparse_transpose_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sparse_transpose_layer
Return
Applicative
Origial documentation for Builder.sparse_transpose_layer
def sparse_transpose_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sparse_transpose, ...)
Arguments
size
: the size of the resulting layer- All other *args and **kwargs are forwarded to
tf.contrib.layers.fully_connected
Return
Builder
Origial documentation for tf.sparse_transpose
def sparse_transpose(sp_input, perm=None, name=None):
Transposes a SparseTensor
The returned tensor's dimension i will correspond to the input dimension
perm[i]
. If perm
is not given, it is set to (n-1...0), where n is
the rank of the input tensor. Hence by default, this operation performs a
regular matrix transpose on 2-D input Tensors.
For example, if sp_input
has shape [4, 5]
and indices
/ values
:
[0, 3]: b [0, 1]: a [3, 1]: d [2, 0]: c
then the output will be a SparseTensor
of shape [5, 4]
and
indices
/ values
:
[0, 2]: c [1, 0]: a [1, 3]: d [3, 0]: b
Args:
sp_input: The input SparseTensor
.
perm: A permutation of the dimensions of sp_input
.
name: A name prefix for the returned tensors (optional)
Returns:
A transposed SparseTensor
.
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 split(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.split, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.split
Return
Applicative
Origial documentation for Builder.split
def split(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.split
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.split
def split(split_dim, num_split, value, name="split")
Splits a tensor into num_split
tensors along one dimension.
Splits value
along dimension split_dim
into num_split
smaller tensors.
Requires that num_split
evenly divide value.shape[split_dim]
.
For example:
```python
'value' is a tensor with shape [5, 30]
Split 'value' into 3 tensors along dimension 1
split0, split1, split2 = tf.split(1, 3, value) tf.shape(split0) ==> [5, 10] ```
Note: If you are splitting along an axis by the length of that axis, consider using unpack, e.g.
python
num_items = t.get_shape()[axis].value
[tf.squeeze(s, [axis]) for s in tf.split(axis, num_items, t)]
can be rewritten as
python
tf.unpack(t, axis=axis)
Args:
split_dim: A 0-D int32
Tensor
. The dimension along which to split.
Must be in the range [0, rank(value))
.
num_split: A Python integer. The number of ways to split.
value: The Tensor
to split.
name: A name for the operation (optional).
Returns:
num_split
Tensor
objects resulting from splitting value
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def split_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.split_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.split_layer
Return
Applicative
Origial documentation for Builder.split_layer
def split_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.split, ...)
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.split
def split(split_dim, num_split, value, name="split"):
Splits a tensor into num_split
tensors along one dimension.
Splits value
along dimension split_dim
into num_split
smaller tensors.
Requires that num_split
evenly divide value.shape[split_dim]
.
For example:
```python
'value' is a tensor with shape [5, 30]
Split 'value' into 3 tensors along dimension 1
split0, split1, split2 = tf.split(1, 3, value) tf.shape(split0) ==> [5, 10] ```
Note: If you are splitting along an axis by the length of that axis, consider using unpack, e.g.
python
num_items = t.get_shape()[axis].value
[tf.squeeze(s, [axis]) for s in tf.split(axis, num_items, t)]
can be rewritten as
python
tf.unpack(t, axis=axis)
Args:
split_dim: A 0-D int32
Tensor
. The dimension along which to split.
Must be in the range [0, rank(value))
.
num_split: A Python integer. The number of ways to split.
value: The Tensor
to split.
name: A name for the operation (optional).
Returns:
num_split
Tensor
objects resulting from splitting value
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def sqrt(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sqrt, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sqrt
Return
Applicative
Origial documentation for Builder.sqrt
def sqrt(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.sqrt
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.sqrt
def sqrt(x, name=None)
Computes square root of x element-wise.
I.e., (y = \sqrt{x} = x^{1/2}).
Args:
x: A Tensor
or SparseTensor
. Must be one of the following types: half
,
float32
, float64
, 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 sqrt_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.sqrt_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.sqrt_layer
Return
Applicative
Origial documentation for Builder.sqrt_layer
def sqrt_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.sqrt, ...)
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.sqrt
def sqrt(x, name=None):
Computes square root of x element-wise.
I.e., (y = \sqrt{x} = x^{1/2}).
Args:
x: A Tensor
or SparseTensor
. Must be one of the following types: half
,
float32
, float64
, 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 square(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.square, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.square
Return
Applicative
Origial documentation for Builder.square
def square(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.square
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.square
def square(x, name=None)
Computes square of x element-wise.
I.e., (y = x * x = x^2).
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
. 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 square_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.square_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.square_layer
Return
Applicative
Origial documentation for Builder.square_layer
def square_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.square, ...)
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.square
def square(x, name=None):
Computes square of x element-wise.
I.e., (y = x * x = x^2).
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
. 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 squared_difference(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.squared_difference, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.squared_difference
Return
Applicative
Origial documentation for Builder.squared_difference
def squared_difference(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.squared_difference
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.squared_difference
def squared_difference(x, y, name=None)
Returns (x - y)(x - y) element-wise.
NOTE: SquaredDifference
supports broadcasting. More about broadcasting
here
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
y: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def squared_difference_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.squared_difference_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.squared_difference_layer
Return
Applicative
Origial documentation for Builder.squared_difference_layer
def squared_difference_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.squared_difference, ...)
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.squared_difference
def squared_difference(x, y, name=None):
Returns (x - y)(x - y) element-wise.
NOTE: SquaredDifference
supports broadcasting. More about broadcasting
here
Args:
x: A Tensor
. Must be one of the following types: half
, float32
, float64
, int32
, int64
, complex64
, complex128
.
y: A Tensor
. Must have the same type as x
.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as x
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def squeeze(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.squeeze, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.squeeze
Return
Applicative
Origial documentation for Builder.squeeze
def squeeze(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.squeeze
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.squeeze
def squeeze(input, squeeze_dims=None, name=None)
Removes dimensions of size 1 from the shape of a tensor.
Given a tensor input
, this operation returns a tensor of the same type with
all dimensions of size 1 removed. If you don't want to remove all size 1
dimensions, you can remove specific size 1 dimensions by specifying
squeeze_dims
.
For example:
```prettyprint
't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3] ```
Or, to remove specific size 1 dimensions:
```prettyprint
't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1] ```
Args:
input: A Tensor
. The input
to squeeze.
squeeze_dims: An optional list of ints
. Defaults to []
.
If specified, only squeezes the dimensions listed. The dimension
index starts at 0. It is an error to squeeze a dimension that is not 1.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as input
.
Contains the same data as input
, but has one or more dimensions of
size 1 removed.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def squeeze_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.squeeze_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.squeeze_layer
Return
Applicative
Origial documentation for Builder.squeeze_layer
def squeeze_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.squeeze, ...)
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.squeeze
def squeeze(input, squeeze_dims=None, name=None):
Removes dimensions of size 1 from the shape of a tensor.
Given a tensor input
, this operation returns a tensor of the same type with
all dimensions of size 1 removed. If you don't want to remove all size 1
dimensions, you can remove specific size 1 dimensions by specifying
squeeze_dims
.
For example:
```prettyprint
't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t)) ==> [2, 3] ```
Or, to remove specific size 1 dimensions:
```prettyprint
't' is a tensor of shape [1, 2, 1, 3, 1, 1]
shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1] ```
Args:
input: A Tensor
. The input
to squeeze.
squeeze_dims: An optional list of ints
. Defaults to []
.
If specified, only squeezes the dimensions listed. The dimension
index starts at 0. It is an error to squeeze a dimension that is not 1.
name: A name for the operation (optional).
Returns:
A Tensor
. Has the same type as input
.
Contains the same data as input
, but has one or more dimensions of
size 1 removed.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def state_saving_rnn(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.state_saving_rnn, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.state_saving_rnn
Return
Applicative
Origial documentation for Builder.state_saving_rnn
def state_saving_rnn(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.nn.state_saving_rnn
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.state_saving_rnn
def state_saving_rnn(cell, inputs, state_saver, state_name, sequence_length=None, scope=None)
RNN that accepts a state saver for time-truncated RNN calculation.
Args:
cell: An instance of RNNCell
.
inputs: A length T list of inputs, each a Tensor
of shape
[batch_size, input_size]
.
state_saver: A state saver object with methods state
and save_state
.
state_name: Python string or tuple of strings. The name to use with the
state_saver. If the cell returns tuples of states (i.e.,
cell.state_size
is a tuple) then state_name
should be a tuple of
strings having the same length as cell.state_size
. Otherwise it should
be a single string.
sequence_length: (optional) An int32/int64 vector size [batch_size].
See the documentation for rnn() for more details about sequence_length.
scope: VariableScope for the created subgraph; defaults to "RNN".
Returns: A pair (outputs, state) where: outputs is a length T list of outputs (one for each input) states is the final state
Raises:
TypeError: If cell
is not an instance of RNNCell.
ValueError: If inputs
is None
or an empty list, or if the arity and
type of state_name
does not match that of cell.state_size
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def state_saving_rnn_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.state_saving_rnn_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.state_saving_rnn_layer
Return
Applicative
Origial documentation for Builder.state_saving_rnn_layer
def state_saving_rnn_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.nn.state_saving_rnn, ...)
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.state_saving_rnn
def state_saving_rnn(cell, inputs, state_saver, state_name, sequence_length=None, scope=None):
RNN that accepts a state saver for time-truncated RNN calculation.
Args:
cell: An instance of RNNCell
.
inputs: A length T list of inputs, each a Tensor
of shape
[batch_size, input_size]
.
state_saver: A state saver object with methods state
and save_state
.
state_name: Python string or tuple of strings. The name to use with the
state_saver. If the cell returns tuples of states (i.e.,
cell.state_size
is a tuple) then state_name
should be a tuple of
strings having the same length as cell.state_size
. Otherwise it should
be a single string.
sequence_length: (optional) An int32/int64 vector size [batch_size].
See the documentation for rnn() for more details about sequence_length.
scope: VariableScope for the created subgraph; defaults to "RNN".
Returns: A pair (outputs, state) where: outputs is a length T list of outputs (one for each input) states is the final state
Raises:
TypeError: If cell
is not an instance of RNNCell.
ValueError: If inputs
is None
or an empty list, or if the arity and
type of state_name
does not match that of cell.state_size
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def stop_gradient(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.stop_gradient, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.stop_gradient
Return
Applicative
Origial documentation for Builder.stop_gradient
def stop_gradient(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.stop_gradient
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.stop_gradient
def stop_gradient(input, name=None)
Stops gradient computation.
When executed in a graph, this op outputs its input tensor as-is.
When building ops to compute gradients, this op prevents the contribution of its inputs to be taken into account. Normally, the gradient generator adds ops to a graph to compute the derivatives of a specified 'loss' by recursively finding out inputs that contributed to its computation. If you insert this op in the graph it inputs are masked from the gradient generator. They are not taken into account for computing gradients.
This is useful any time you want to compute a value with TensorFlow but need to pretend that the value was a constant. Some examples include:
- The EM algorithm where the M-step should not involve backpropagation through the output of the E-step.
- Contrastive divergence training of Boltzmann machines where, when differentiating the energy function, the training must not backpropagate through the graph that generated the samples from the model.
- Adversarial training, where no backprop should happen through the adversarial example generation process.
Args:
input: A Tensor
.
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 stop_gradient_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.stop_gradient_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.stop_gradient_layer
Return
Applicative
Origial documentation for Builder.stop_gradient_layer
def stop_gradient_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.stop_gradient, ...)
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.stop_gradient
def stop_gradient(input, name=None):
Stops gradient computation.
When executed in a graph, this op outputs its input tensor as-is.
When building ops to compute gradients, this op prevents the contribution of its inputs to be taken into account. Normally, the gradient generator adds ops to a graph to compute the derivatives of a specified 'loss' by recursively finding out inputs that contributed to its computation. If you insert this op in the graph it inputs are masked from the gradient generator. They are not taken into account for computing gradients.
This is useful any time you want to compute a value with TensorFlow but need to pretend that the value was a constant. Some examples include:
- The EM algorithm where the M-step should not involve backpropagation through the output of the E-step.
- Contrastive divergence training of Boltzmann machines where, when differentiating the energy function, the training must not backpropagate through the graph that generated the samples from the model.
- Adversarial training, where no backprop should happen through the adversarial example generation process.
Args:
input: A Tensor
.
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 store_on(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.store_on, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.store_on
Return
Applicative
Origial documentation for Builder.store_on
def store_on(builder, other):
None
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def strided_slice(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.strided_slice, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.strided_slice
Return
Applicative
Origial documentation for Builder.strided_slice
def strided_slice(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.strided_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.strided_slice
def strided_slice(input_, begin, end, strides, begin_mask=0, end_mask=0, ellipsis_mask=0, new_axis_mask=0, shrink_axis_mask=0, var=None, name=None)
Extracts a strided slice from a tensor.
To a first order, this operation extracts a slice of size end - begin
from a tensor input
starting at the location specified by begin
. The slice continues by adding
stride
to the begin
index until all dimensions are not less than end
.
Note that components of stride can be negative, which causes a reverse
slice.
This operation can be thought of an encoding of a numpy style sliced
range. Given a python slice input[
begin
, end
, and strides
will be all length n. n is in general
not the same dimensionality as input
.
For the ith spec,
begin_mask
, end_mask
, ellipsis_mask
, new_axis_mask
,
and shrink_axis_mask
will have the ith bit corresponding to
the ith spec.
If the ith bit of begin_mask
is non-zero, begin[i]
is ignored and
the fullest possible range in that dimension is used instead.
end_mask
works analogously, except with the end range.
foo[5:,:,:3]
on a 7x8x9 tensor is equivalent to foo[5:7,0:8,0:3]
.
foo[::-1]
reverses a tensor with shape 8.
If the ith bit of ellipsis_mask
, as many unspecified dimensions
as needed will be inserted between other dimensions. Only one
non-zero bit is allowed in ellipsis_mask
.
For example foo[3:5,...,4:5]
on a shape 10x3x3x10 tensor is
equivalent to foo[3:5,:,:,4:5]
and
foo[3:5,...]
is equivalent to foo[3:5,:,:,:]
.
If the ith bit of new_axis_mask
is one, then a begin
,
end
, and stride
are ignored and a new length 1 dimension is
added at this point in the output tensor.
For example foo[3:5,4]
on a 10x8 tensor produces a shape 2 tensor
whereas foo[3:5,4:5]
produces a shape 2x1 tensor with shrink_mask
being 1<<1 == 2.
If the ith bit of shrink_axis_mask
is one, then begin
,
end[i]
, and stride[i]
are used to do a slice in the appropriate
dimension, but the output tensor will be reduced in dimensionality
by one. This is only valid if the ith entry of slice[i]==1.
NOTE: begin
and end
are zero-indexed.
strides` entries must be non-zero.
```
'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], [2, 1, 3], [1, 1, 1]) ==> [[[3, 3, 3]]] tf.slice(input, [1, 0, 0], [2, 2, 3], [1, 1, 1]) ==> [[[3, 3, 3], [4, 4, 4]]] tf.slice(input, [1, 1, 0], [2, -1, 3], [1, -1, 1]) ==>[[[4, 4, 4], [3, 3, 3]]] ```
Args:
input_: A Tensor
.
begin: An int32
or int64
Tensor
.
end: An int32
or int64
Tensor
.
strides: An int32
or int64
Tensor
.
begin_mask: An int32
mask.
end_mask: An int32
mask.
ellipsis_mask: An int32
mask.
new_axis_mask: An int32
mask.
shrink_axis_mask: An int32
mask.
var: The variable coresponding to input_
or None
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 strided_slice_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.strided_slice_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.strided_slice_layer
Return
Applicative
Origial documentation for Builder.strided_slice_layer
def strided_slice_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.strided_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.strided_slice
def strided_slice(input_, begin, end, strides, begin_mask=0, end_mask=0, ellipsis_mask=0, new_axis_mask=0, shrink_axis_mask=0, var=None, name=None):
Extracts a strided slice from a tensor.
To a first order, this operation extracts a slice of size end - begin
from a tensor input
starting at the location specified by begin
. The slice continues by adding
stride
to the begin
index until all dimensions are not less than end
.
Note that components of stride can be negative, which causes a reverse
slice.
This operation can be thought of an encoding of a numpy style sliced
range. Given a python slice input[
begin
, end
, and strides
will be all length n. n is in general
not the same dimensionality as input
.
For the ith spec,
begin_mask
, end_mask
, ellipsis_mask
, new_axis_mask
,
and shrink_axis_mask
will have the ith bit corresponding to
the ith spec.
If the ith bit of begin_mask
is non-zero, begin[i]
is ignored and
the fullest possible range in that dimension is used instead.
end_mask
works analogously, except with the end range.
foo[5:,:,:3]
on a 7x8x9 tensor is equivalent to foo[5:7,0:8,0:3]
.
foo[::-1]
reverses a tensor with shape 8.
If the ith bit of ellipsis_mask
, as many unspecified dimensions
as needed will be inserted between other dimensions. Only one
non-zero bit is allowed in ellipsis_mask
.
For example foo[3:5,...,4:5]
on a shape 10x3x3x10 tensor is
equivalent to foo[3:5,:,:,4:5]
and
foo[3:5,...]
is equivalent to foo[3:5,:,:,:]
.
If the ith bit of new_axis_mask
is one, then a begin
,
end
, and stride
are ignored and a new length 1 dimension is
added at this point in the output tensor.
For example foo[3:5,4]
on a 10x8 tensor produces a shape 2 tensor
whereas foo[3:5,4:5]
produces a shape 2x1 tensor with shrink_mask
being 1<<1 == 2.
If the ith bit of shrink_axis_mask
is one, then begin
,
end[i]
, and stride[i]
are used to do a slice in the appropriate
dimension, but the output tensor will be reduced in dimensionality
by one. This is only valid if the ith entry of slice[i]==1.
NOTE: begin
and end
are zero-indexed.
strides` entries must be non-zero.
```
'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], [2, 1, 3], [1, 1, 1]) ==> [[[3, 3, 3]]] tf.slice(input, [1, 0, 0], [2, 2, 3], [1, 1, 1]) ==> [[[3, 3, 3], [4, 4, 4]]] tf.slice(input, [1, 1, 0], [2, -1, 3], [1, -1, 1]) ==>[[[4, 4, 4], [3, 3, 3]]] ```
Args:
input_: A Tensor
.
begin: An int32
or int64
Tensor
.
end: An int32
or int64
Tensor
.
strides: An int32
or int64
Tensor
.
begin_mask: An int32
mask.
end_mask: An int32
mask.
ellipsis_mask: An int32
mask.
new_axis_mask: An int32
mask.
shrink_axis_mask: An int32
mask.
var: The variable coresponding to input_
or None
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 string_join(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_join, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_join
Return
Applicative
Origial documentation for Builder.string_join
def string_join(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_join
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.string_join
def string_join(inputs, separator=None, name=None)
Joins the strings in the given list of string tensors into one tensor;
with the given separator (default is an empty separator).
Args:
inputs: A list of at least 1 Tensor
objects of type string
.
A list of string tensors. The tensors must all have the same shape,
or be scalars. Scalars may be mixed in; these will be broadcast to the shape
of non-scalar inputs.
separator: An optional string
. Defaults to ""
.
string, an optional join separator.
name: A name for the operation (optional).
Returns:
A Tensor
of type string
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_join_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_join_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_join_layer
Return
Applicative
Origial documentation for Builder.string_join_layer
def string_join_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_join, ...)
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.string_join
def string_join(inputs, separator=None, name=None):
Joins the strings in the given list of string tensors into one tensor;
with the given separator (default is an empty separator).
Args:
inputs: A list of at least 1 Tensor
objects of type string
.
A list of string tensors. The tensors must all have the same shape,
or be scalars. Scalars may be mixed in; these will be broadcast to the shape
of non-scalar inputs.
separator: An optional string
. Defaults to ""
.
string, an optional join separator.
name: A name for the operation (optional).
Returns:
A Tensor
of type string
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_split(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_split, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_split
Return
Applicative
Origial documentation for Builder.string_split
def string_split(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_split
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.string_split
def string_split(source, delimiter=" ")
Split elements of source
based on delimiter
into a SparseTensor
.
Let N be the size of source (typically N will be the batch size). Split each
element of source
based on delimiter
and return a SparseTensor
containing the splitted tokens. Empty tokens are ignored.
If delimiter
is an empty string, each element of the source
is split
into individual 1 character strings.
For example: N = 2, source[0] is 'hello world' and source[1] is 'a b c', then the output will be
st.indices = [0, 0; 0, 1; 1, 0; 1, 1; 1, 2] st.shape = [2, 3] st.values = ['hello', 'world', 'a', 'b', 'c']
Args:
source: 1-D
string Tensor
, the strings to split.
delimiter: 0-D
string Tensor
, the delimiter character, the string should
be length 0 or 1.
Returns:
A SparseTensor
of rank 2
, the strings split according to the delimiter.
The first column of the indices corresponds to the row in source
and the
second column corresponds to the index of the split component in this row.
Raises: ValueError: If delimiter is not a character.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_split_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_split_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_split_layer
Return
Applicative
Origial documentation for Builder.string_split_layer
def string_split_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_split, ...)
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.string_split
def string_split(source, delimiter=" "):
Split elements of source
based on delimiter
into a SparseTensor
.
Let N be the size of source (typically N will be the batch size). Split each
element of source
based on delimiter
and return a SparseTensor
containing the splitted tokens. Empty tokens are ignored.
If delimiter
is an empty string, each element of the source
is split
into individual 1 character strings.
For example: N = 2, source[0] is 'hello world' and source[1] is 'a b c', then the output will be
st.indices = [0, 0; 0, 1; 1, 0; 1, 1; 1, 2] st.shape = [2, 3] st.values = ['hello', 'world', 'a', 'b', 'c']
Args:
source: 1-D
string Tensor
, the strings to split.
delimiter: 0-D
string Tensor
, the delimiter character, the string should
be length 0 or 1.
Returns:
A SparseTensor
of rank 2
, the strings split according to the delimiter.
The first column of the indices corresponds to the row in source
and the
second column corresponds to the index of the split component in this row.
Raises: ValueError: If delimiter is not a character.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket
def string_to_hash_bucket(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_to_hash_bucket
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.string_to_hash_bucket
def string_to_hash_bucket(string_tensor, num_buckets, name=None)
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the process.
Note that the hash function may change from time to time.
This functionality will be deprecated and it's recommended to use
tf.string_to_hash_bucket_fast()
or tf.string_to_hash_bucket_strong()
.
Args:
string_tensor: A Tensor
of type string
.
num_buckets: An int
that is >= 1
. The number of buckets.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket_fast(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket_fast, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket_fast
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket_fast
def string_to_hash_bucket_fast(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_to_hash_bucket_fast
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.string_to_hash_bucket_fast
def string_to_hash_bucket_fast(input, num_buckets, name=None)
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the
process and will never change. However, it is not suitable for cryptography.
This function may be used when CPU time is scarce and inputs are trusted or
unimportant. There is a risk of adversaries constructing inputs that all hash
to the same bucket. To prevent this problem, use a strong hash function with
tf.string_to_hash_bucket_strong
.
Args:
input: A Tensor
of type string
. The strings to assign a hash bucket.
num_buckets: An int
that is >= 1
. The number of buckets.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket_fast_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket_fast_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket_fast_layer
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket_fast_layer
def string_to_hash_bucket_fast_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_to_hash_bucket_fast, ...)
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.string_to_hash_bucket_fast
def string_to_hash_bucket_fast(input, num_buckets, name=None):
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the
process and will never change. However, it is not suitable for cryptography.
This function may be used when CPU time is scarce and inputs are trusted or
unimportant. There is a risk of adversaries constructing inputs that all hash
to the same bucket. To prevent this problem, use a strong hash function with
tf.string_to_hash_bucket_strong
.
Args:
input: A Tensor
of type string
. The strings to assign a hash bucket.
num_buckets: An int
that is >= 1
. The number of buckets.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket_layer
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket_layer
def string_to_hash_bucket_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_to_hash_bucket, ...)
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.string_to_hash_bucket
def string_to_hash_bucket(string_tensor, num_buckets, name=None):
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the process.
Note that the hash function may change from time to time.
This functionality will be deprecated and it's recommended to use
tf.string_to_hash_bucket_fast()
or tf.string_to_hash_bucket_strong()
.
Args:
string_tensor: A Tensor
of type string
.
num_buckets: An int
that is >= 1
. The number of buckets.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket_strong(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket_strong, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket_strong
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket_strong
def string_to_hash_bucket_strong(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_to_hash_bucket_strong
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.string_to_hash_bucket_strong
def string_to_hash_bucket_strong(input, num_buckets, key, name=None)
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the
process. The hash function is a keyed hash function, where attribute key
defines the key of the hash function. key
is an array of 2 elements.
A strong hash is important when inputs may be malicious, e.g. URLs with additional components. Adversaries could try to make their inputs hash to the same bucket for a denial-of-service attack or to skew the results. A strong hash prevents this by making it dificult, if not infeasible, to compute inputs that hash to the same bucket. This comes at a cost of roughly 4x higher compute time than tf.string_to_hash_bucket_fast.
Args:
input: A Tensor
of type string
. The strings to assign a hash bucket.
num_buckets: An int
that is >= 1
. The number of buckets.
key: A list of ints
.
The key for the keyed hash function passed as a list of two uint64
elements.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_hash_bucket_strong_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_hash_bucket_strong_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_hash_bucket_strong_layer
Return
Applicative
Origial documentation for Builder.string_to_hash_bucket_strong_layer
def string_to_hash_bucket_strong_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_to_hash_bucket_strong, ...)
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.string_to_hash_bucket_strong
def string_to_hash_bucket_strong(input, num_buckets, key, name=None):
Converts each string in the input Tensor to its hash mod by a number of buckets.
The hash function is deterministic on the content of the string within the
process. The hash function is a keyed hash function, where attribute key
defines the key of the hash function. key
is an array of 2 elements.
A strong hash is important when inputs may be malicious, e.g. URLs with additional components. Adversaries could try to make their inputs hash to the same bucket for a denial-of-service attack or to skew the results. A strong hash prevents this by making it dificult, if not infeasible, to compute inputs that hash to the same bucket. This comes at a cost of roughly 4x higher compute time than tf.string_to_hash_bucket_fast.
Args:
input: A Tensor
of type string
. The strings to assign a hash bucket.
num_buckets: An int
that is >= 1
. The number of buckets.
key: A list of ints
.
The key for the keyed hash function passed as a list of two uint64
elements.
name: A name for the operation (optional).
Returns:
A Tensor
of type int64
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_number(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_number, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_number
Return
Applicative
Origial documentation for Builder.string_to_number
def string_to_number(builder):
THIS METHOD IS AUTOMATICALLY GENERATED
@immutable
This method is a lifted version the function tf.string_to_number
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.string_to_number
def string_to_number(string_tensor, out_type=None, name=None)
Converts each string in the input Tensor to the specified numeric type.
(Note that int32 overflow results in an error while float overflow results in a rounded value.)
Args:
string_tensor: A Tensor
of type string
.
out_type: An optional tf.DType
from: tf.float32, tf.int32
. Defaults to tf.float32
.
The numeric type to interpret each string in string_tensor as.
name: A name for the operation (optional).
Returns:
A Tensor
of type out_type
.
A Tensor of the same shape as the input string_tensor
.
def _method(app, *args, **kwargs): def _lambda(builder): g = getattr(builder, f.__name__) return g(*args, **kwargs) return app.compose(_lambda)
def string_to_number_layer(
app, *args, **kwargs)
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .compose(Builder.string_to_number_layer, ...)
Arguments
- All other *args and **kwargs are forwarded to
Builder.string_to_number_layer
Return
Applicative
Origial documentation for Builder.string_to_number_layer
def string_to_number_layer(builder, size):
THIS METHOD IS AUTOMATICALLY GENERATED
Alias for .fully_connected(size, activation_fn = tf.string_to_number, ...)
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.string_to_number
def string_to_number(string_tensor, out_type=None, name=None):
Converts each string in the input Tensor to the specified numeric type.
(Note that int32 overflow results in an error while float overflow results in a rounded value.)
Args: