jina.types.ndarray.sparse.tensorflow

class jina.types.ndarray.sparse.tensorflow.SparseNdArray(*args, **kwargs)[source]

Bases: jina.types.ndarray.sparse.BaseSparseNdArray

Tensorflow powered sparse ndarray, i.e. SparseTensor

Parameters

proto – the protobuf message, when not given then create a new one via get_null_proto()

sparse_constructor(indices, values, shape)[source]

Sparse NdArray constructor, must be implemented by subclass

Parameters
  • indices (np.ndarray) – the indices of the sparse array

  • values (np.ndarray) – the values of the sparse array

  • shape (List[int]) – the shape of the dense array

Return type

SparseTensor

Returns

sparse_parser(value)[source]

Parsing a Sparse NdArray to indices, values and shape, must be implemented by subclass

Parameters

value (SparseTensor) – the sparse ndarray

Returns

a Dict with three entries {‘indices’: …, ‘values’:…, ‘shape’:…}