tensorflow代码实现:Inception模块

引言: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模块架构图

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值