function scatter(tensor, indices, elementShape, numElements) {
      if (indices.length !== tensor.shape[0]) {
          throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${indices.length} vs. ${tensor.shape[0]}`);
      }
      const maxIndex = Math.max(...indices);
      if (numElements != null && numElements !== -1 && maxIndex >= numElements) {
          throw new Error(`Max index must be < array size (${maxIndex}  vs. ${numElements})`);
      }
      const list = new TensorList([], elementShape, tensor.dtype, numElements);
      const tensors = tfc.unstack(tensor, 0);
      indices.forEach((value, index) => {
          list.setItem(value, tensors[index]);
      });
      return list;
  }
/**
   * Put tensors at specific indices of a stacked tensor into a TensorList.
   * @param indices list of indices on how to scatter the tensor.
   * @param tensor input tensor.
   * @param elementShape the shape of the future elements of the list
   * @param numElements the number of elements to scatter
   */
Put tensors at specific indices of a stacked tensor into a TensorList.
@param indices list of indices on how to scatter the tensor.
@param tensor input tensor.
@param elementShape the shape of the future elements of the list
@param numElements the number of elements to scatter
Put tensors at specific indices of a stacked tensor into a TensorList . @param indices list of indices on how to scatter the tensor . @param tensor input tensor . @param elementShape the shape of the future elements of the list @param numElements the number of elements to scatter
function scatter(tensor, indices, elementShape, numElements) {
      if (indices.length !== tensor.shape[0]) {
          throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${indices.length} vs. ${tensor.shape[0]}`);
      }
      const maxIndex = Math.max(...indices);
      if (numElements != null && numElements !== -1 && maxIndex >= numElements) {
          throw new Error(`Max index must be < array size (${maxIndex}  vs. ${numElements})`);
      }
      const list = new TensorList([], elementShape, tensor.dtype, numElements);
      const tensors = tfc.unstack(tensor, 0);
      indices.forEach((value, index) => {
          list.setItem(value, tensors[index]);
      });
      return list;
  }
function scatter ( tensor , indices , elementShape , numElements ) { if ( indices . length !== tensor . shape [ 0 ] ) { throw new Error ( ` ${ indices . length } ${ tensor . shape [ 0 ] } ` ) ; } const maxIndex = Math . max ( ... indices ) ; if ( numElements != null && numElements !== - 1 && maxIndex >= numElements ) { throw new Error ( ` ${ maxIndex } ${ numElements } ` ) ; } const list = new TensorList ( [ ] , elementShape , tensor . dtype , numElements ) ; const tensors = tfc . unstack ( tensor , 0 ) ; indices . forEach ( ( value , index ) => { list . setItem ( value , tensors [ index ] ) ; } ) ; return list ; }
Put tensors at specific indices of a stacked tensor into a TensorList.
Put tensors at specific indices of a stacked tensor into a TensorList .