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

Function preprocessConv2DInput

tfjs-layers/src/layers/convolutional.ts:40–51  ·  view source on GitHub ↗
(
    x: Tensor, dataFormat: DataFormat)

Source from the content-addressed store, hash-verified

38 * @param dataFormat
39 */
40export function preprocessConv2DInput(
41 x: Tensor, dataFormat: DataFormat): Tensor {
42 // TODO(cais): Cast type to float32 if not.
43 return tidy(() => {
44 checkDataFormat(dataFormat);
45 if (dataFormat === 'channelsFirst') {
46 return tfc.transpose(x, [0, 2, 3, 1]); // NCHW -> NHWC.
47 } else {
48 return x;
49 }
50 });
51}
52
53/**
54 * Transpose and cast the input before the conv3d.

Callers 3

pool2dFunction · 0.90
depthwiseConv2dFunction · 0.90
conv2dWithBiasActivationFunction · 0.85

Calls 3

tidyFunction · 0.90
checkDataFormatFunction · 0.90
transposeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…