Skip to content

TF2 tensor generators

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