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

Function tensor4d

tfjs-core/src/ops/tensor4d.ts:48–66  ·  view source on GitHub ↗
(
    values: TensorLike4D, shape?: [number, number, number, number],
    dtype?: DataType)

Source from the content-addressed store, hash-verified

46 * @doc {heading: 'Tensors', subheading: 'Creation'}
47 */
48export function tensor4d(
49 values: TensorLike4D, shape?: [number, number, number, number],
50 dtype?: DataType): Tensor4D {
51 assertNonNull(values);
52 if (shape != null && shape.length !== 4) {
53 throw new Error('tensor4d() requires shape to have four numbers');
54 }
55 const inferredShape = inferShape(values, dtype);
56 if (inferredShape.length !== 4 && inferredShape.length !== 1) {
57 throw new Error(
58 'tensor4d() requires values to be number[][][][] or flat/TypedArray');
59 }
60 if (inferredShape.length === 1 && shape == null) {
61 throw new Error(
62 'tensor4d() requires shape to be provided when `values` ' +
63 'are a flat array');
64 }
65 return makeTensor(values, shape, inferredShape, dtype) as Tensor4D;
66}

Callers 8

pooling_test.tsFile · 0.90
recurrent_test.tsFile · 0.90
core_test.tsFile · 0.90
qr_test.tsFile · 0.90

Calls 3

assertNonNullFunction · 0.90
inferShapeFunction · 0.90
makeTensorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…