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

Function depthwiseConv2d

tfjs-layers/src/layers/convolutional_depthwise.ts:45–73  ·  view source on GitHub ↗
(
    x: Tensor, depthwiseKernel: Tensor, strides: [number, number] = [1, 1],
    padding = 'valid', dataFormat?: DataFormat,
    dilationRate?: [number, number])

Source from the content-addressed store, hash-verified

43 * @throws ValueError If depthwiseKernel is not a 4D array.
44 */
45export function depthwiseConv2d(
46 x: Tensor, depthwiseKernel: Tensor, strides: [number, number] = [1, 1],
47 padding = 'valid', dataFormat?: DataFormat,
48 dilationRate?: [number, number]): Tensor {
49 return tidy(() => {
50 if (dataFormat == null) {
51 dataFormat = imageDataFormat();
52 }
53 checkDataFormat(dataFormat);
54 let y = preprocessConv2DInput(x, dataFormat);
55 if (x.rank !== 4) {
56 throw new ValueError(
57 `Input for depthwiseConv2d is required to be 4-D, but is instead ` +
58 `${x.rank}-D`);
59 }
60 if (depthwiseKernel.rank !== 4) {
61 throw new ValueError(
62 `depthwiseKernel is required to be 4-D, but is instead ` +
63 `${depthwiseKernel.rank}-D`);
64 }
65 y = tfc.depthwiseConv2d(
66 y as Tensor4D, depthwiseKernel as Tensor4D, strides,
67 padding === 'same' ? 'same' : 'valid', 'NHWC', dilationRate);
68 if (dataFormat === 'channelsFirst') {
69 y = tfc.transpose(y, [0, 3, 1, 2]);
70 }
71 return y;
72 });
73}
74
75export declare interface DepthwiseConv2DLayerArgs extends BaseConvLayerArgs {
76 /**

Callers 2

callMethod · 0.70

Calls 6

tidyFunction · 0.90
imageDataFormatFunction · 0.90
checkDataFormatFunction · 0.90
preprocessConv2DInputFunction · 0.90
depthwiseConv2dMethod · 0.80
transposeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…