(batch: number, logs?: UnresolvedLogs)
| 233 | } |
| 234 | |
| 235 | override async onBatchEnd(batch: number, logs?: UnresolvedLogs) { |
| 236 | if (logs == null) { |
| 237 | logs = {}; |
| 238 | } |
| 239 | const batchSize = logs['size'] == null ? 0 : logs['size'] as number; |
| 240 | this.seen += batchSize; |
| 241 | for (const key in logs) { |
| 242 | const value = logs[key]; |
| 243 | if (typeof value === 'number') { |
| 244 | if (!this.totals.hasOwnProperty(key)) { |
| 245 | this.totals[key] = 0; |
| 246 | } |
| 247 | this.totals[key] = this.totals[key] as number + value * batchSize; |
| 248 | } else { |
| 249 | let oldTotalsToDispose: Scalar; |
| 250 | if (key in this.totals) { |
| 251 | oldTotalsToDispose = this.totals[key] as Scalar; |
| 252 | } else { |
| 253 | this.totals[key] = 0; |
| 254 | } |
| 255 | const total: Scalar = |
| 256 | tidy(() => add((this.totals[key]), mul(value, batchSize))); |
| 257 | this.totals[key] = total; |
| 258 | if (oldTotalsToDispose != null) { |
| 259 | oldTotalsToDispose.dispose(); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | override async onEpochEnd(epoch: number, logs?: UnresolvedLogs) { |
| 266 | if (logs != null) { |
no test coverage detected