tensorflow代码实现:Inception模块

来源:互联网 发布:php eval 执行函数 编辑:程序博客网 时间:2024/06/05 12:49

引言:Inception-v3模型总共有46层,由11个Inception模块组成。

import tensorflow as tfslim=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模块架构图

阅读全文
0 0
原创粉丝点击