简体   繁体   中英

How to understand the first argument of the Keras Conv2D layer?

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')

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM