Front:
- The shape of the factors affecting shape:
- 1. convolution kernel size
- 2.stride step
- 3.padding mode
official:
- K - the number of convolution kernels
- F - convolution kernel size
- S - step
- P - filled peripheryThe number of layers
use
- Apparently under the valid mode, direct volume, not discarded
我推导的valid模式下的计算方式(以 W 举例):
W2 = (W1 - F)/S + 1
- SAME mode
- How to determine P
- Equation 1 using the calculated theoretical output shape, and then using the formula P 2 backstepping
Official 1
Official 2
- Equation 1 using the calculated theoretical output shape, and then using the formula P 2 backstepping
- How to determine P
5×5的图像
3×3的卷积核
步长 2
padding SAME
import tensorflow as tf
import numpy as np
pic = tf.constant(value=np.ones((5, 5), dtype=np.float32), shape=(1,5,5,1))
W = tf.constant(value=np.ones((3, 3), dtype=np.float32), shape=(3,3,1,1))
output = tf.nn.conv2d(pic, W, strides=[1, 2, 2, 1], padding='SAME')
with tf.Session() as sess:
print(output.eval().shape)
"""
运行结果:
(1, 3, 3, 1)
"""
to sum up
- Analyzing output tensor shape shape
reference
Depth learning the basics - convolution calculation formula and pooling
appreciated CNN layer and the convolution calculation cell layer