LostTech.TensorFlow : API Documentation

Type tf.sparse

Namespace tensorflow

Public static methods

SparseTensor cross(IEnumerable<SparseTensor> inputs, string name)

Generates sparse cross from a list of sparse and dense tensors.

For example, if the inputs are

* inputs[0]: SparseTensor with shape = [2, 2] [0, 0]: "a" [1, 0]: "b" [1, 1]: "c" * inputs[1]: SparseTensor with shape = [2, 1] [0, 0]: "d" [1, 0]: "e" * inputs[2]: Tensor [["f"], ["g"]]

then the output will be:

shape = [2, 2] [0, 0]: "a_X_d_X_f" [1, 0]: "b_X_e_X_g" [1, 1]: "c_X_e_X_g"
Parameters
IEnumerable<SparseTensor> inputs
An iterable of `Tensor` or `SparseTensor`.
string name
Optional name for the op.
Returns
SparseTensor
A `SparseTensor` of type `string`.

object cross_dyn(object inputs, object name)

Generates sparse cross from a list of sparse and dense tensors.

For example, if the inputs are

* inputs[0]: SparseTensor with shape = [2, 2] [0, 0]: "a" [1, 0]: "b" [1, 1]: "c" * inputs[1]: SparseTensor with shape = [2, 1] [0, 0]: "d" [1, 0]: "e" * inputs[2]: Tensor [["f"], ["g"]]

then the output will be:

shape = [2, 2] [0, 0]: "a_X_d_X_f" [1, 0]: "b_X_e_X_g" [1, 1]: "c_X_e_X_g"
Parameters
object inputs
An iterable of `Tensor` or `SparseTensor`.
object name
Optional name for the op.
Returns
object
A `SparseTensor` of type `string`.

SparseTensor cross_hashed(IEnumerable<SparseTensor> inputs, int num_buckets, Nullable<int> hash_key, string name)

Generates hashed sparse cross from a list of sparse and dense tensors.

For example, if the inputs are

* inputs[0]: SparseTensor with shape = [2, 2] [0, 0]: "a" [1, 0]: "b" [1, 1]: "c" * inputs[1]: SparseTensor with shape = [2, 1] [0, 0]: "d" [1, 0]: "e" * inputs[2]: Tensor [["f"], ["g"]]

then the output will be:

shape = [2, 2] [0, 0]: FingerprintCat64( Fingerprint64("f"), FingerprintCat64( Fingerprint64("d"), Fingerprint64("a"))) [1, 0]: FingerprintCat64( Fingerprint64("g"), FingerprintCat64( Fingerprint64("e"), Fingerprint64("b"))) [1, 1]: FingerprintCat64( Fingerprint64("g"), FingerprintCat64( Fingerprint64("e"), Fingerprint64("c")))
Parameters
IEnumerable<SparseTensor> inputs
An iterable of `Tensor` or `SparseTensor`.
int num_buckets
An `int` that is `>= 0`. output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
Nullable<int> hash_key
Integer hash_key that will be used by the `FingerprintCat64` function. If not given, will use a default key.
string name
Optional name for the op.
Returns
SparseTensor
A `SparseTensor` of type `int64`.

object cross_hashed_dyn(object inputs, ImplicitContainer<T> num_buckets, object hash_key, object name)

Generates hashed sparse cross from a list of sparse and dense tensors.

For example, if the inputs are

* inputs[0]: SparseTensor with shape = [2, 2] [0, 0]: "a" [1, 0]: "b" [1, 1]: "c" * inputs[1]: SparseTensor with shape = [2, 1] [0, 0]: "d" [1, 0]: "e" * inputs[2]: Tensor [["f"], ["g"]]

then the output will be:

shape = [2, 2] [0, 0]: FingerprintCat64( Fingerprint64("f"), FingerprintCat64( Fingerprint64("d"), Fingerprint64("a"))) [1, 0]: FingerprintCat64( Fingerprint64("g"), FingerprintCat64( Fingerprint64("e"), Fingerprint64("b"))) [1, 1]: FingerprintCat64( Fingerprint64("g"), FingerprintCat64( Fingerprint64("e"), Fingerprint64("c")))
Parameters
object inputs
An iterable of `Tensor` or `SparseTensor`.
ImplicitContainer<T> num_buckets
An `int` that is `>= 0`. output = hashed_value%num_buckets if num_buckets > 0 else hashed_value.
object hash_key
Integer hash_key that will be used by the `FingerprintCat64` function. If not given, will use a default key.
object name
Optional name for the op.
Returns
object
A `SparseTensor` of type `int64`.

SparseTensor expand_dims(SparseTensor sp_input, ValueTuple<PythonClassContainer, PythonClassContainer> axis, string name)

Inserts a dimension of 1 into a tensor's shape.

Given a tensor `sp_input`, this operation inserts a dimension of 1 at the dimension index `axis` of `sp_input`'s shape. The dimension index `axis` starts at zero; if you specify a negative number for `axis` it is counted backwards from the end.
Parameters
SparseTensor sp_input
A `SparseTensor`.
ValueTuple<PythonClassContainer, PythonClassContainer> axis
0-D (scalar). Specifies the dimension index at which to expand the shape of `input`. Must be in the range `[-rank(sp_input) - 1, rank(sp_input)]`.
string name
The name of the output `SparseTensor`.
Returns
SparseTensor
A `SparseTensor` with the same data as `sp_input`, but its shape has an additional dimension of size 1 added.

SparseTensor expand_dims(SparseTensor sp_input, int axis, string name)

Inserts a dimension of 1 into a tensor's shape.

Given a tensor `sp_input`, this operation inserts a dimension of 1 at the dimension index `axis` of `sp_input`'s shape. The dimension index `axis` starts at zero; if you specify a negative number for `axis` it is counted backwards from the end.
Parameters
SparseTensor sp_input
A `SparseTensor`.
int axis
0-D (scalar). Specifies the dimension index at which to expand the shape of `input`. Must be in the range `[-rank(sp_input) - 1, rank(sp_input)]`.
string name
The name of the output `SparseTensor`.
Returns
SparseTensor
A `SparseTensor` with the same data as `sp_input`, but its shape has an additional dimension of size 1 added.

SparseTensor expand_dims(SparseTensor sp_input, IGraphNodeBase axis, string name)

Inserts a dimension of 1 into a tensor's shape.

Given a tensor `sp_input`, this operation inserts a dimension of 1 at the dimension index `axis` of `sp_input`'s shape. The dimension index `axis` starts at zero; if you specify a negative number for `axis` it is counted backwards from the end.
Parameters
SparseTensor sp_input
A `SparseTensor`.
IGraphNodeBase axis
0-D (scalar). Specifies the dimension index at which to expand the shape of `input`. Must be in the range `[-rank(sp_input) - 1, rank(sp_input)]`.
string name
The name of the output `SparseTensor`.
Returns
SparseTensor
A `SparseTensor` with the same data as `sp_input`, but its shape has an additional dimension of size 1 added.

SparseTensor eye(int num_rows, int num_columns, ImplicitContainer<T> dtype, string name)

Creates a two-dimensional sparse tensor with ones along the diagonal.
Parameters
int num_rows
Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix.
int num_columns
Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`.
ImplicitContainer<T> dtype
The type of element in the resulting `Tensor`.
string name
A name for this `Op`. Defaults to "eye".
Returns
SparseTensor
A `SparseTensor` of shape [num_rows, num_columns] with ones along the diagonal.

SparseTensor eye(int num_rows, IGraphNodeBase num_columns, ImplicitContainer<T> dtype, string name)

Creates a two-dimensional sparse tensor with ones along the diagonal.
Parameters
int num_rows
Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix.
IGraphNodeBase num_columns
Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`.
ImplicitContainer<T> dtype
The type of element in the resulting `Tensor`.
string name
A name for this `Op`. Defaults to "eye".
Returns
SparseTensor
A `SparseTensor` of shape [num_rows, num_columns] with ones along the diagonal.

SparseTensor eye(IGraphNodeBase num_rows, int num_columns, ImplicitContainer<T> dtype, string name)

Creates a two-dimensional sparse tensor with ones along the diagonal.
Parameters
IGraphNodeBase num_rows
Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix.
int num_columns
Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`.
ImplicitContainer<T> dtype
The type of element in the resulting `Tensor`.
string name
A name for this `Op`. Defaults to "eye".
Returns
SparseTensor
A `SparseTensor` of shape [num_rows, num_columns] with ones along the diagonal.

SparseTensor eye(IGraphNodeBase num_rows, IGraphNodeBase num_columns, ImplicitContainer<T> dtype, string name)

Creates a two-dimensional sparse tensor with ones along the diagonal.
Parameters
IGraphNodeBase num_rows
Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix.
IGraphNodeBase num_columns
Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`.
ImplicitContainer<T> dtype
The type of element in the resulting `Tensor`.
string name
A name for this `Op`. Defaults to "eye".
Returns
SparseTensor
A `SparseTensor` of shape [num_rows, num_columns] with ones along the diagonal.

object eye_dyn(object num_rows, object num_columns, ImplicitContainer<T> dtype, object name)

Creates a two-dimensional sparse tensor with ones along the diagonal.
Parameters
object num_rows
Non-negative integer or `int32` scalar `tensor` giving the number of rows in the resulting matrix.
object num_columns
Optional non-negative integer or `int32` scalar `tensor` giving the number of columns in the resulting matrix. Defaults to `num_rows`.
ImplicitContainer<T> dtype
The type of element in the resulting `Tensor`.
object name
A name for this `Op`. Defaults to "eye".
Returns
object
A `SparseTensor` of shape [num_rows, num_columns] with ones along the diagonal.

SparseTensor from_dense(IGraphNodeBase tensor, string name)

Converts a dense tensor into a sparse tensor.

Only elements not equal to zero will be present in the result. The resulting `SparseTensor` has the same dtype and shape as the input.
Parameters
IGraphNodeBase tensor
A dense `Tensor` to be converted to a `SparseTensor`.
string name
Optional name for the op.
Returns
SparseTensor
The `SparseTensor`.

object from_dense_dyn(object tensor, object name)

Converts a dense tensor into a sparse tensor.

Only elements not equal to zero will be present in the result. The resulting `SparseTensor` has the same dtype and shape as the input.
Parameters
object tensor
A dense `Tensor` to be converted to a `SparseTensor`.
object name
Optional name for the op.
Returns
object
The `SparseTensor`.

Public properties

PythonFunctionContainer cross_fn get;

PythonFunctionContainer cross_hashed_fn get;

PythonFunctionContainer expand_dims_fn get;

PythonFunctionContainer from_dense_fn get;