Creates rank-2 tf.Tensor with the provided values, shape and dtype.
tf.Tensor
The same functionality can be achieved with tf.tensor, but in general we recommend using tf.tensor2d as it makes the code more readable.
tf.tensor
tf.tensor2d
// Pass a nested array.tf.tensor2d([[1, 2], [3, 4]]).print(); Copy
// Pass a nested array.tf.tensor2d([[1, 2], [3, 4]]).print();
// Pass a flat array and specify a shape.tf.tensor2d([1, 2, 3, 4], [2, 2]).print(); Copy
// Pass a flat array and specify a shape.tf.tensor2d([1, 2, 3, 4], [2, 2]).print();
The values of the tensor. Can be nested array of numbers, or a flat array, or a TypedArray.
TypedArray
Optional
The shape of the tensor. If not provided, it is inferred from values.
values
The data type.
Creates rank-2
tf.Tensor
with the provided values, shape and dtype.The same functionality can be achieved with
tf.tensor
, but in general we recommend usingtf.tensor2d
as it makes the code more readable.