1

I'm following the TensorFlow 2 quickstart for experts guide and trying to understand the first argument of making an instance of Conv2D.

filters: Integer, the dimensionality of the output space
    (i.e. the number of output filters in the convolution).

As the guide uses the same 32 for the batch size and filters, is there a specific reason to choose 32, and should both of these parameters always match each other?

Relevant code:

train_ds = tf.data.Dataset.from_tensor_slices(
    (x_train, y_train)).shuffle(10000).batch(32)

... ...

self.conv1 = Conv2D(32, 3, activation='relu')
Shukai Ni
  • 457
  • 2
  • 6
  • 17

2 Answers2

3

What is batch size in neural network?
What is the number of filter in CNN?

Summary:
The batch size defines the number of samples that will be propagated through the network.

The number of filters is the number of neurons, since each neuron performs a different convolution on the input to the layer (more precisely, the neurons' input weights form convolution kernels).

Hence, these parameters need not be same.

Kashinath Patekar
  • 1,083
  • 9
  • 23
0

In general, people tend to use powers of 2 for different hyperparameters in neural nets. It is not definitively proven to be more effective, but there are schools of thought that point to it being the most effective approach. In terms of the number of filters, filters are meant to detect features. If you add more filters, it should be able to capture more complex features, whether they be visual or physical. The drawback to increasing the number of filters in each layer is the added parameters that are associated with it. This makes your model take up more memory, and it will take longer to train as there are more parameters to update.

WVJoe
  • 515
  • 7
  • 21