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

Function flattenTensorOrArrayOrMap

tfjs-layers/src/engine/training_dataset.ts:262–285  ·  view source on GitHub ↗
(
    inputOrOutput: string, names: string[], values: TensorOrArrayOrMap)

Source from the content-addressed store, hash-verified

260}
261
262function flattenTensorOrArrayOrMap(
263 inputOrOutput: string, names: string[], values: TensorOrArrayOrMap) {
264 if (values instanceof tfc.Tensor) {
265 return [values];
266 } else if (Array.isArray(values)) {
267 tfc.util.assert(
268 values.length === names.length,
269 () => `Received an array of ${values.length} Tensors, but expected ${
270 names.length} to match the ${inputOrOutput} keys ${names}.`);
271 return values;
272 } else {
273 const result: tfc.Tensor[] = [];
274 // Check that all the required keys are available.
275 for (const name of names) {
276 if (values[name] == null) {
277 throw new ValueError(
278 `The feature data generated by the dataset lacks the required ` +
279 `${inputOrOutput} key '${name}'.`);
280 }
281 result.push(values[name]);
282 }
283 return result;
284 }
285}
286
287function standardizeTensorValidationData<T>(
288 data:

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…