简体   繁体   English

Keras Conv2D层的第一个参数怎么理解?

[英]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 .我正在关注专家指南的 TensorFlow 2 快速入门指南,并试图理解创建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?由于指南对batch大小和filters使用相同的32 ,选择32是否有特定原因,这两个参数是否应该始终相互匹配?

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? 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.一般来说,人们倾向于对神经网络中的不同超参数使用 2 的幂。 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.这会使您的 model 占用更多的 memory,并且由于要更新的参数更多,因此训练需要更长的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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