Search code examples
machine-learningneural-networkconv-neural-networkfeature-extraction

How can I calculate the number of weights and bias values in a single CNN layer?


Given the following image, how can I calculate the number of parameters:

CNN Layer

This particular layer consists of 4x4 convolutions and 64 feature maps; how can I complete a calculation that satisfies my initial question?

Update - Full Architecture


Solution

  • Filter size is contains N * kernel_size * kernel_size weight parameters and one for each channel so

    N * kernel_size * kernel_size* n_channels then N bais parmaters so the final cacluation for this layer is n_params = N * kernel_size * kernel_size* n_channels + N


    N : number of features

    kernel_size : is conv2d shape (height and width)

    n_channels : is the number of channels

    n_params : is the total number of your parameters

    Ex

    n_params = 64 * (4 * 4) * 3 + 64 = 3136