MCPcopy Create free account
hub / github.com/tensorflow/tfjs / formatLogsAsMetricsContent

Method formatLogsAsMetricsContent

tfjs-node/src/callbacks.ts:125–142  ·  view source on GitHub ↗
(logs: Logs, maxMetricsLength?: number)

Source from the content-addressed store, hash-verified

123 }
124
125 private formatLogsAsMetricsContent(logs: Logs, maxMetricsLength?: number):
126 string {
127 let metricsContent = '';
128 const keys = Object.keys(logs).sort();
129 for (const key of keys) {
130 if (this.isFieldRelevant(key)) {
131 const value = logs[key];
132 metricsContent += `${key}=${getSuccinctNumberDisplay(value)} `;
133 }
134 }
135
136 if (maxMetricsLength != null && metricsContent.length > maxMetricsLength) {
137 // Cut off metrics strings that are too long to avoid new lines being
138 // constantly created.
139 metricsContent = metricsContent.slice(0, maxMetricsLength - 3) + '...';
140 }
141 return metricsContent;
142 }
143
144 private isFieldRelevant(key: string) {
145 return key !== 'batch' && key !== 'size';

Callers 1

constructorMethod · 0.95

Calls 3

isFieldRelevantMethod · 0.95
getSuccinctNumberDisplayFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected