Checks the input tensor mathes the given shape.
Given an input tensor, returns a new tensor with the same values as the input tensor with shape shape.
shape
The method supports the null value in tensor. It will still check the shapes, and null is a placeholder.
const x = tf.tensor1d([1, 2, 3, 4]);const y = tf.tensor1d([1, null, 3, 4]);const z = tf.tensor2d([1, 2, 3, 4], [2,2]);tf.ensureShape(x, [4]).print();tf.ensureShape(y, [4]).print();tf.ensureShape(z, [null, 2]).print(); Copy
const x = tf.tensor1d([1, 2, 3, 4]);const y = tf.tensor1d([1, null, 3, 4]);const z = tf.tensor2d([1, 2, 3, 4], [2,2]);tf.ensureShape(x, [4]).print();tf.ensureShape(y, [4]).print();tf.ensureShape(z, [null, 2]).print();
The input tensor to be ensured.
A TensorShape representing the shape of this tensor, an array or null.
Generated using TypeDoc
Checks the input tensor mathes the given shape.
Given an input tensor, returns a new tensor with the same values as the input tensor with shape
shape
.The method supports the null value in tensor. It will still check the shapes, and null is a placeholder.