conv2d包含了两个输入参数:x,filter。一个输出参数:output shape。
参考源码:https://github.com/tensorflow/tfjs-core/blob/master/src/ops/conv_util.ts, 版本号7833594
输入参数的处理
conv2d有两个输入参数:x和filter。
* @param x The input tensor, of rank 4 or rank 3, of shape
* `[batch, height, width, inChannels]`. If rank 3, batch of 1 is
* assumed.
* @param filter The filter, rank 4, of shape
* `[filterHeight, filterWidth, inDepth, outDepth]`.
输入参数x可以是4D, 3D。
4D输入NHWC:[batch, height, width, channels]
inShape: [number, number, number, number] = [2, 2, 2, inputDepth];
3D输入HWC:[height, width, channels]
inputShape: [number, number, number] = [4, 4, inputDepth];
如果输入2D,则会报错。譬如将const x: any = tf.tensor2d([1, 2, 3, 4], [2, 2]);