split(length, tensor) {
          if (tensor.dtype !== this.dtype) {
              throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${tensor.dtype}`);
          }
          let totalLength = 0;
          const cumulativeLengths = length.map(len => {
              totalLength += len;
              return totalLength;
          });
          if (totalLength !== tensor.shape[0]) {
              throw new Error(`Expected sum of lengths to be equal to
          tensor.shape[0], but sum of lengths is
        ${totalLength}, and tensor's shape is: ${tensor.shape}`);
          }
          if (!this.dynamicSize && length.length !== this.maxSize) {
              throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${length.length}), ` +
                  'and the TensorArray is not marked as dynamically resizeable');
          }
          const elementPerRow = totalLength === 0 ? 0 : tensor.size / totalLength;
          const tensors = [];
          tfc.tidy(() => {
              tensor = tfc.reshape(tensor, [1, totalLength, elementPerRow]);
              for (let i = 0; i < length.length; ++i) {
                  const previousLength = (i === 0) ? 0 : cumulativeLengths[i - 1];
                  const indices = [0, previousLength, 0];
                  const sizes = [1, length[i], elementPerRow];
                  tensors[i] = tfc.reshape(tfc.slice(tensor, indices, sizes), this.elementShape);
              }
              return tensors;
          });
          const indices = [];
          for (let i = 0; i < length.length; i++) {
              indices[i] = i;
          }
          this.writeMany(indices, tensors);
      }
/**
       * Split the values of a Tensor into the TensorArray.
       * @param length number[] with the lengths to use when splitting value along
       *    its first dimension.
       * @param tensor Tensor, the tensor to split.
       */
Split the values of a Tensor into the TensorArray.
@param length number[] with the lengths to use when splitting value along
its first dimension.
@param tensor Tensor, the tensor to split.
Split the values of a Tensor into the TensorArray . @param length number [] with the lengths to use when splitting value along its first dimension . @param tensor Tensor the tensor to split .
split(length, tensor) {
          if (tensor.dtype !== this.dtype) {
              throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${tensor.dtype}`);
          }
          let totalLength = 0;
          const cumulativeLengths = length.map(len => {
              totalLength += len;
              return totalLength;
          });
          if (totalLength !== tensor.shape[0]) {
              throw new Error(`Expected sum of lengths to be equal to
          tensor.shape[0], but sum of lengths is
        ${totalLength}, and tensor's shape is: ${tensor.shape}`);
          }
          if (!this.dynamicSize && length.length !== this.maxSize) {
              throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${length.length}), ` +
                  'and the TensorArray is not marked as dynamically resizeable');
          }
          const elementPerRow = totalLength === 0 ? 0 : tensor.size / totalLength;
          const tensors = [];
          tfc.tidy(() => {
              tensor = tfc.reshape(tensor, [1, totalLength, elementPerRow]);
              for (let i = 0; i < length.length; ++i) {
                  const previousLength = (i === 0) ? 0 : cumulativeLengths[i - 1];
                  const indices = [0, previousLength, 0];
                  const sizes = [1, length[i], elementPerRow];
                  tensors[i] = tfc.reshape(tfc.slice(tensor, indices, sizes), this.elementShape);
              }
              return tensors;
          });
          const indices = [];
          for (let i = 0; i < length.length; i++) {
              indices[i] = i;
          }
          this.writeMany(indices, tensors);
      }
split ( length , tensor ) { if ( tensor . dtype !== this . dtype ) { throw new Error ( ` ${ this . dtype } ${ tensor . dtype } ` ) ; } let totalLength = 0 ; const cumulativeLengths = length . map ( len => { totalLength += len ; return totalLength ; } ) ; if ( totalLength !== tensor . shape [ 0 ] ) { throw new Error ( ` ${ totalLength } ${ tensor . shape } ` ) ; } if ( ! this . dynamicSize && length . length !== this . maxSize ) { throw new Error ( ` ${ this . maxSize } ${ length . length } ` + 'and the TensorArray is not marked as dynamically resizeable' ) ; } const elementPerRow = totalLength === 0 ? 0 : tensor . size / totalLength ; const tensors = [ ] ; tfc . tidy ( ( ) => { tensor = tfc . reshape ( tensor , [ 1 , totalLength , elementPerRow ] ) ; for ( let i = 0 ; i < length . length ; ++ i ) { const previousLength = ( i === 0 ) ? 0 : cumulativeLengths [ i - 1 ] ; const indices = [ 0 , previousLength , 0 ] ; const sizes = [ 1 , length [ i ] , elementPerRow ] ; tensors [ i ] = tfc . reshape ( tfc . slice ( tensor , indices , sizes ) , this . elementShape ) ; } return tensors ; } ) ; const indices = [ ] ; for ( let i = 0 ; i < length . length ; i ++ ) { indices [ i ] = i ; } this . writeMany ( indices , tensors ) ; }
Split the values of a Tensor into the TensorArray.
Split the values of a Tensor into the TensorArray .