MCPcopy
hub / github.com/tensorflow/tfjs / normalizeArray

Function normalizeArray

tfjs-layers/src/utils/conv_utils.ts:24–45  ·  view source on GitHub ↗
(
    value: number|number[], n: number, name: string)

Source from the content-addressed store, hash-verified

22 * @returns An array of numbers.
23 */
24export function normalizeArray(
25 value: number|number[], n: number, name: string): number[] {
26 if (typeof value === 'number') {
27 return pyListRepeat(value, n);
28 } else {
29 if (value.length !== n) {
30 throw new ValueError(
31 `The ${name} argument must be an integer or tuple of ${n} integers.` +
32 ` Received: ${value.length} elements.`);
33 }
34 for (let i = 0; i < n; ++i) {
35 const singleValue = value[i];
36 if (!isInteger(singleValue)) {
37 throw new ValueError(
38 `The ${name} argument must be an integer or tuple of ${n}` +
39 ` integers. Received: ${JSON.stringify(value)} including a` +
40 ` non-integer number ${singleValue}`);
41 }
42 }
43 return value;
44 }
45}
46
47/**
48 * Determines output length of a convolution given input length.

Callers 2

constructorFunction · 0.90
constructorMethod · 0.90

Calls 2

pyListRepeatFunction · 0.90
isIntegerFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…