Skip to content

TF2 tensor generators

Raffi Khatchadourian edited this page Jun 14, 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