flatten
flatten(input: any[] | Mat | Tensor) : any[]
param input
can be any matrix like structure; a vector, 2d javascript array, Mat object, Tensor, etc
returns: any[]
- A 1-dimensional javascript array with all elements from input
. The order of elements follows the dimensions or shape order.
This function is a useful tool for taking a multidimensional matrix or even a 2d matrix and "flattening" it into a 1d javascript array. Here is an example: