<jupyter_start><jupyter_text>Conv2d(卷积核)tf.keras.layers.Conv2D(  &nbsp;&nbsp;&nbsp;&nbsp;filters, kernel_size, strides=(1, 1), padding='valid',  &nbsp;&nbsp;&nbsp;&nbsp;data_format=None, dilation_rate=(1, 1), groups=1, &nbsp;&nbsp;&nbsp;&nbsp;activation=None,  &nbsp;&nbsp;&nbsp;&nbsp;use_bias=True, kernel_initializer='glorot_uniform',  &nbsp;&nbsp;&nbsp;&nbsp;bias_initializer='zeros', kernel_regularizer=None,  &nbsp;&nbsp;&nbsp;&nbsp;bias_regularizer=None, activity_regularizer=None, &nbsp;&nbsp;&nbsp;&nbsp;kernel_constraint=None,  &nbsp;&nbsp;&nbsp;&nbsp;bias_constraint=None, **kwargs  )<jupyter_code>filters = 1
# 构造一个二维卷积层，它具有1个输出通道和形状为（1，2）的卷积核
conv2d = tf.keras.layers.Conv2D(filters, (1, 2), use_bias=False)
## Padding
## 'same': keep the size the same
# 注意!!! 这里每边都填充了1行或1列，因此总共添加了2行或2列
conv2d = tf.keras.layers.Conv2D(filters, kernel_size=3, padding='same')
conv2d = tf.keras.layers.Conv2D(filters, kernel_size=(5, 3), padding='same')<jupyter_output><empty_output><jupyter_text>stride<jupyter_code>conv2d = tf.keras.layers.Conv2D(filters, kernel_size=3, padding='same', strides=2)
conv2d = tf.keras.layers.Conv2D(filters, kernel_size=(3,5), padding='valid',strides=(3, 4))<jupyter_output><empty_output><jupyter_text>Pooling layer(汇聚层)tf.keras.layers.MaxPool2D(  &nbsp;&nbsp;&nbsp;&nbsp;pool_size=(2, 2),  &nbsp;&nbsp;&nbsp;&nbsp;strides=None,  &nbsp;&nbsp;&nbsp;&nbsp;padding='valid',  &nbsp;&nbsp;&nbsp;&nbsp;data_format=None,  )<jupyter_code>X = tf.reshape(tf.range(16, dtype=tf.float32), (1, 4, 4, 1))
X<jupyter_output><empty_output><jupyter_text>默认情况下，步幅与汇聚窗口的大小相同。 因此，如果我们使用形状为(3, 3)的汇聚窗口，那么默认情况下，我们得到的步幅形状为(3, 3)。<jupyter_code>pool2d = tf.keras.layers.MaxPool2D(pool_size=[3, 3])
pool2d(X)
pool2d = tf.keras.layers.MaxPool2D(pool_size=[3, 3], padding='valid',
                                   strides=2)
pool2d = tf.keras.layers.MaxPool2D(pool_size=[2, 3], padding='valid',
                                   strides=(2, 3))<jupyter_output><empty_output><jupyter_text>Batch Normalization<jupyter_code>bn = tf.keras.layers.BatchNormalization()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1819484240687679, 'fraction_numerical': 0.03199617956064948, 'mean_word_length': 8.479638009049774, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '10840', 'license': 'MIT', 'n_tokens_mistral': 911, 'n_tokens_neox': 926, 'n_words': 88, 'path': '05_conv_layer/tf_conv_layer.ipynb', 'repo_name': 'JiaheXu/Machine-Learning-Codebase', 'size': '2094'}