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

Function batchConcat

tfjs-data/src/dataset.ts:691–705  ·  view source on GitHub ↗

* Assembles a list of same-shaped numbers, number arrays, or Tensors * into a single new Tensor where axis 0 is the batch dimension.

(arrays: T[])

Source from the content-addressed store, hash-verified

689 * into a single new Tensor where axis 0 is the batch dimension.
690 */
691function batchConcat<T extends(TensorLike | tf.Tensor)>(arrays: T[]):
692 tf.Tensor {
693 if (arrays.length === 0) {
694 // We can't return an empty Tensor because we don't know the element shape.
695 throw new Error('Can\'t make a batch of zero elements.');
696 }
697
698 if (arrays[0] instanceof tf.Tensor) {
699 // Input is an array of Tensors
700 return tf.stack(arrays as tf.Tensor[]);
701 } else {
702 // Input is a possibly-nested array of numbers.
703 return tf.tensor(arrays as TensorLike);
704 }
705}

Callers 1

deepBatchConcatFunction · 0.85

Calls 1

stackMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…