(
x: Tensor, depthwiseKernel: Tensor, strides: [number, number] = [1, 1],
padding = 'valid', dataFormat?: DataFormat,
dilationRate?: [number, number])
| 43 | * @throws ValueError If depthwiseKernel is not a 4D array. |
| 44 | */ |
| 45 | export 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 | |
| 75 | export declare interface DepthwiseConv2DLayerArgs extends BaseConvLayerArgs { |
| 76 | /** |
no test coverage detected
searching dependent graphs…