(variable: LayerVariable, value: Tensor, momentum: number)
| 374 | |
| 375 | const doMovingAverage = |
| 376 | (variable: LayerVariable, value: Tensor, momentum: number): void => { |
| 377 | tfc.tidy(() => { |
| 378 | const decay = 1 - momentum; |
| 379 | const origValue = variable.read(); |
| 380 | const updateDelta = tfc.mul(tfc.sub(origValue, value), decay); |
| 381 | variable.write(tfc.sub(origValue, updateDelta)); |
| 382 | }); |
| 383 | }; |
| 384 | |
| 385 | // Perform updates to moving mean and moving variance for training. |
| 386 | // Porting Note: In PyKeras, these updates to `movingMean` and |