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

Method getLossIdentifiers

tfjs-layers/src/engine/training.ts:1928–1957  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1926 }
1927
1928 private getLossIdentifiers(): LossIdentifier|LossIdentifier[]|
1929 {[outputName: string]: LossIdentifier} {
1930 let lossNames: LossIdentifier|LossIdentifier[]|
1931 {[outputName: string]: LossIdentifier};
1932 if (typeof this.loss === 'string') {
1933 lossNames = toSnakeCase(this.loss) as LossIdentifier;
1934 } else if (Array.isArray(this.loss)) {
1935 for (const loss of this.loss) {
1936 if (typeof loss !== 'string') {
1937 throw new Error('Serialization of non-string loss is not supported.');
1938 }
1939 }
1940 lossNames = (this.loss as string[]).map(name => toSnakeCase(name)) as
1941 LossIdentifier[];
1942 } else {
1943 const outputNames = Object.keys(this.loss);
1944 lossNames = {} as {[outputName: string]: LossIdentifier};
1945 const losses =
1946 this.loss as {[outputName: string]: LossOrMetricFn | string};
1947 for (const outputName of outputNames) {
1948 if (typeof losses[outputName] === 'string') {
1949 lossNames[outputName] =
1950 toSnakeCase(losses[outputName] as string) as LossIdentifier;
1951 } else {
1952 throw new Error('Serialization of non-string loss is not supported.');
1953 }
1954 }
1955 }
1956 return lossNames;
1957 }
1958
1959 private getMetricIdentifiers(): MetricsIdentifier[]|
1960 {[key: string]: MetricsIdentifier} {

Callers 1

getTrainingConfigMethod · 0.95

Calls 1

toSnakeCaseFunction · 0.90

Tested by

no test coverage detected