Question about W dimension

4 dimensions_in_weights
hello, would you please explain why the W filter has 4 dimensions?
A_prev shape =(m , n_H_prev, n_W_prev, n_C_prev)
W shape = (n_H_prev, n_W_prev, n_C_prev, n_C)
I think it should be:
(n_H_prev, n_W_prev, n_C_prev)
n_C here is the number of filters ?

To understand this, you need to think carefully about how convolutions work. The number of output channels is a hyperparameter: you just define how many output channels you want at each layer. Then what happens is that for each output channel you want, you are convolving across all channels of the input, right? So for each output channel, you need a filter of shape f x f x nC_{prev}, where nC_{prev} is the number of channels of the input. So you end up with a 4D array consisting of nC items of the previously described shape. Prof Ng has chosen to define W with the output channel dimension as the last dimension of the tensor.

If this doesn’t make sense as stated, then it’s probably a good idea to go back and watch the lectures again where Prof Ng originally shows us how all this stuff works.

1 Like

Hello Paulin,
Thanks for answering my question.
yes, I completely figure out what you said.
Thanks a lot
(Ahmad Ahmadi)