MCPcopy Index your code
hub / github.com/tensorflow/tfjs / write

Method write

tfjs-layers/src/variables.ts:95–107  ·  view source on GitHub ↗

* Update the value of the Variable. * * @param newVal: The new value to update to. Must be consistent with the * dtype and shape of the Variable. * @return This Variable.

(newVal: Tensor)

Source from the content-addressed store, hash-verified

93 * @return This Variable.
94 */
95 write(newVal: Tensor) {
96 // TODO(cais): Once TF.js Core supports Tensor.dtype, check dtype match.
97 this.assertNotDisposed();
98 checkShapesMatch(this.val, newVal);
99 // Skip updating if this is the exact same tensor.
100 if (this.val.id !== newVal.id) {
101 this.val.assign(newVal);
102 if (this.constraint != null) {
103 this.val.assign(this.constraint.apply(this.val));
104 }
105 }
106 return this;
107 }
108
109 /**
110 * Dispose this LayersVariable instance from memory.

Callers

nothing calls this directly

Calls 4

assertNotDisposedMethod · 0.95
checkShapesMatchFunction · 0.85
assignMethod · 0.80
applyMethod · 0.45

Tested by

no test coverage detected