* 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)
| 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. |
nothing calls this directly
no test coverage detected