MCPcopy
hub / github.com/tensorflow/tfjs / assign

Method assign

tfjs-core/src/tensor.ts:583–597  ·  view source on GitHub ↗

* Assign a new `tf.Tensor` to this variable. The new `tf.Tensor` must have * the same shape and dtype as the old `tf.Tensor`. * * @param newValue New tensor to be assigned to this variable. * * @doc {heading: 'Tensors', subheading: 'Classes'}

(newValue: Tensor<R>)

Source from the content-addressed store, hash-verified

581 * @doc {heading: 'Tensors', subheading: 'Classes'}
582 */
583 assign(newValue: Tensor<R>): void {
584 if (newValue.dtype !== this.dtype) {
585 throw new Error(
586 `dtype of the new value (${newValue.dtype}) and ` +
587 `previous value (${this.dtype}) must match`);
588 }
589 if (!util.arraysEqual(newValue.shape, this.shape)) {
590 throw new Error(
591 `shape of the new value (${newValue.shape}) and ` +
592 `previous value (${this.shape}) must match`);
593 }
594 trackerFn().disposeTensor(this);
595 this.dataId = newValue.dataId;
596 trackerFn().incRef(this, null /* backend */);
597 }
598
599 override dispose(): void {
600 trackerFn().disposeVariable(this);

Callers 15

historyFunction · 0.80
fitCallbacksFunction · 0.80
confusionMatrixFunction · 0.80
histogramFunction · 0.80
heatmapFunction · 0.80
barchartFunction · 0.80
linechartFunction · 0.80
tableFunction · 0.80
scatterplotFunction · 0.80
subSurfaceFunction · 0.80
naiveMergeFunction · 0.80

Calls 2

disposeTensorMethod · 0.65
incRefMethod · 0.65

Tested by

no test coverage detected