flatten_to_ndims

tfsnippet.ops.flatten_to_ndims(x, ndims, name=None)

Flatten the front dimensions of x, such that the resulting tensor will have at most ndims dimensions.

Parameters:
  • x (Tensor) – The tensor to be flatten.
  • ndims (int) – The maximum number of dimensions for the resulting tensor.
  • name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns:

(The flatten tensor, the static front shape, and the front shape), or (the original tensor, None, None)

Return type:

(tf.Tensor, tuple[int or None], tuple[int] or tf.Tensor) or (tf.Tensor, None, None)