write(index, tensor) {
          if (this.closed_) {
              throw new Error(`TensorArray ${this.name} has already been closed.`);
          }
          if (index < 0 || !this.dynamicSize && index >= this.maxSize) {
              throw new Error(`Tried to write to index ${index}, but array is not resizeable and size is: ${this.maxSize}`);
          }
          const t = this.tensors[index] || {};
          if (tensor.dtype !== this.dtype) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index},
          because the value dtype is ${tensor.dtype}, but TensorArray dtype is ${this.dtype}.`);
          }
          // Set the shape for the first time write to unknow shape tensor array
          if (this.size() === 0 &&
              (this.elementShape == null || this.elementShape.length === 0)) {
              this.elementShape = tensor.shape;
          }
          assertShapesMatchAllowUndefinedSize(this.elementShape, tensor.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${index}.`);
          if (t.read) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been read.`);
          }
          if (t.written) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been written.`);
          }
          t.tensor = tensor;
          tfc.keep(tensor);
          t.written = true;
          this.tensors[index] = t;
      }
/**
       * Write value into the index of the TensorArray.
       * @param index number the index to write to.
       * @param tensor
       */
Write value into the index of the TensorArray.
@param index number the index to write to.
@param tensor
Write value into the index of the TensorArray . @param index number the index to write to . @param tensor
write(index, tensor) {
          if (this.closed_) {
              throw new Error(`TensorArray ${this.name} has already been closed.`);
          }
          if (index < 0 || !this.dynamicSize && index >= this.maxSize) {
              throw new Error(`Tried to write to index ${index}, but array is not resizeable and size is: ${this.maxSize}`);
          }
          const t = this.tensors[index] || {};
          if (tensor.dtype !== this.dtype) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index},
          because the value dtype is ${tensor.dtype}, but TensorArray dtype is ${this.dtype}.`);
          }
          if (this.size() === 0 &&
              (this.elementShape == null || this.elementShape.length === 0)) {
              this.elementShape = tensor.shape;
          }
          assertShapesMatchAllowUndefinedSize(this.elementShape, tensor.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${index}.`);
          if (t.read) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been read.`);
          }
          if (t.written) {
              throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${index}, because it has already been written.`);
          }
          t.tensor = tensor;
          tfc.keep(tensor);
          t.written = true;
          this.tensors[index] = t;
      }
write ( index , tensor ) { if ( this . closed_ ) { throw new Error ( ` ${ this . name } ` ) ; } if ( index < 0 || ! this . dynamicSize && index >= this . maxSize ) { throw new Error ( ` ${ index } ${ this . maxSize } ` ) ; } const t = this . tensors [ index ] || { } ; if ( tensor . dtype !== this . dtype ) { throw new Error ( ` ${ this . name } ${ index } ${ tensor . dtype } ${ this . dtype } ` ) ; } if ( this . size ( ) === 0 && ( this . elementShape == null || this . elementShape . length === 0 ) ) { this . elementShape = tensor . shape ; } assertShapesMatchAllowUndefinedSize ( this . elementShape , tensor . shape , ` ${ this . name } ${ index } ` ) ; if ( t . read ) { throw new Error ( ` ${ this . name } ${ index } ` ) ; } if ( t . written ) { throw new Error ( ` ${ this . name } ${ index } ` ) ; } t . tensor = tensor ; tfc . keep ( tensor ) ; t . written = true ; this . tensors [ index ] = t ; }
Write value into the index of the TensorArray.
Write value into the index of the TensorArray .
// Set the shape for the first time write to unknow shape tensor array