@ Override public INDArray toFlattened ( Collection < INDArray > matrices ) { int length = 0 ; for ( INDArray m : matrices ) length += m . length ( ) ; INDArray ret = Nd4j . create ( 1 , length ) ; int linearIndex = 0 ; for ( INDArray d : matrices ) { ret . put ( new INDArrayIndex [ ] { NDArrayIndex . interval ( linearIndex , linearIndex + d . length ( ) ) } , d ) ; linearIndex += d . length ( ) ; } return ret ; }
Returns a vector with all of the elements in every nd array equal to the sum of the lengths of the ndarrays