引言:Inception-v3模型总共有46层,由11个Inception模块组成。
import tensorflow as tf
slim=tf.contrib.slim
#slim.arg_scope函数:第一个参数是一个函数列表,在这个列表中的函数将使用默认的参数取值。
with slim.arg_scope([slim.conv2d,slim.max_pool2d,slim.avg_pool2d],stride=1,padding='SAME'):
with tf.variable_scope('Maxed_7c'):
with tf.variable_scope('Branch_0'):
#net=上一层的输出节点矩阵
branch_0=slim.conv2d(net,320,[1,1],scope='Conv2d_0a_1*1')
with tf.variable_scope('Branch_1'):
branch_1=slim.conv2d(net,384,[1,1],scope='Conv2d_0a_1*1')
#tf.concat函数:可以将多个矩阵拼接起来;
#其中第一个参数:拼接的维度,‘3’代表了矩阵是在深度这个维度上进行拼接的。
branch_1=tf.concat(3,[slim.conv2d(branch_1,384,[1,3],scope='Conv2d_0b_1*3'),\
slim.conv2d(branch_1,384,[3,1],scope='Conv2d_0c_3*1')])
with tf.variable_scope('Branch_2'):
branch_2=slim.conv2d(net,448,[1,1],scope='Conv2d_0a_1*1')
branch_2=slim.conv2d(branch_2,384,[3,3],scope='Conv2d_0b_3*3')
branch_2=tf.concat(3,[slim.conv2d(branch_2,384,[1,3],scope='Conv2d_0c_1*3'),\
slim.conv2d(branch_2,384,[3,1],scope='Conv2d_0d_3*1')])
with tf.variable_scope('Branch_3'):
branch_3=slim.avg_pool2d(net,[3,3],scope='AvgPool_0a_3*3')
branch_3=slim.conv2d(branch_3,192,[1,1],scope='Conv2d_0b_1*1')
net=tf.concat(3,[branch_0,branch_1,branch_2,branch_3])
本文介绍了Inception-v3模型中一个特定模块的构建过程,该模块通过多种卷积操作和池化技术来提高特征提取的效率。文章详细展示了如何使用TensorFlow Slim API实现这一复杂结构,并通过不同分支的并行计算最终融合特征。
327

被折叠的 条评论
为什么被折叠?



