* 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[])
| 689 | * into a single new Tensor where axis 0 is the batch dimension. |
| 690 | */ |
| 691 | function 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 | } |
no test coverage detected
searching dependent graphs…