Skip to content

TF2 tensor generators

Tatiana Castro-Vélez edited this page Jun 19, 2023 · 12 revisions
Generator Main alias of Level Description Returns Tensor?
tf.Tensor 1 A tf.Tensor represents a multidimensional array of elements. TRUE
tf.SparseTensor tf.sparse.SparseTensor 1 Represents a sparse tensor. TRUE
tf.ones 1 Creates a tensor with all elements set to one (1). TRUE
tf.fill 1 Creates a tensor filled with a scalar value. TRUE
tf.zeros 1 Creates a tensor with all elements set to zero. TRUE
tf.zeros_like 1 Creates a tensor with all elements set to zero. TRUE
tf.one_hot 1 Returns a one-hot tensor. TRUE
tf.eye 1 Construct an identity matrix, or a batch of matrices. TRUE
tf.Variable 1 A variable maintains shared, persistent state manipulated by a program. FALSE
tf.constant 1 Creates a constant tensor from a tensor-like object. TRUE
tf.convert_to_tensor 1 Converts the given value to a Tensor. TRUE
tf.range 1 Creates a sequence of numbers. TRUE
tf.sparse.SparseTensor 2 Represents a sparse tensor. TRUE
tf.linalg.eye tf.eye 2 Construct an identity matrix, or a batch of matrices. TRUE
tf.keras.Input 2 A Keras tensor is a symbolic tensor-like object, which we augment with certain attributes that allow us to build a Keras model just by knowing the inputs and outputs of the model. FALSE
tf.ragged.constant 2 Constructs a constant RaggedTensor from a nested Python list. TRUE
tf.ragged.range 2 Returns a RaggedTensor containing the specified sequences of numbers. TRUE
tf.RaggedTensor.from_nested_row_lengths 2 Creates a RaggedTensor from a nested list of row_lengths tensors. TRUE
tf.RaggedTensor.from_nested_row_splits 2 Creates a RaggedTensor from a nested list of row_splits tensors. TRUE
tf.RaggedTensor.from_nested_value_rowids 2 Creates a RaggedTensor from a nested list of value_rowids tensors. TRUE
tf.RaggedTensor.from_row_lengths 2 Creates a RaggedTensor with rows partitioned by row_lengths. TRUE
tf.RaggedTensor.from_row_limits 2 Creates a RaggedTensor with rows partitioned by row_limits. TRUE
tf.RaggedTensor.from_row_splits 2 Creates a RaggedTensor with rows partitioned by row_splits. TRUE
tf.RaggedTensor.from_row_starts 2 Creates a RaggedTensor with rows partitioned by row_starts. TRUE
tf.RaggedTensor.from_value_rowids 2 Creates a RaggedTensor with rows partitioned by value_rowids. TRUE
tf.random.gamma 2 Draws shape samples from each of the given Gamma distribution(s). TRUE
tf.random.normal 2 Outputs random values from a normal distribution. TRUE
tf.random.poisson 2 Draws shape samples from each of the given Poisson distribution(s). TRUE
tf.random.uniform 2 Outputs random values from a uniform distribution. TRUE
tf.random.truncated_normal 2 Outputs random values from a truncated normal distribution. TRUE
tf.sparse.eye 2 Creates a two-dimensional sparse tensor with ones along the diagonal. TRUE
tf.experimental.numpy.ndarray tf.Tensor 3 A tf.experimental.numpy.ndarray represents a multidimensional array of elements. TRUE
tf.keras.layers.Input tf.keras.Input 3 A Keras tensor is a symbolic tensor-like object, which we augment with certain attributes that allow us to build a Keras model just by knowing the inputs and outputs of the model. FALSE