tensorflow-densenet-resnet-inception网络


该文件包含一个densenet,一个resnet,一个inception网络。
资源截图
代码片段和文件信息
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import numpy as np
import tensorflow as tf
import argparse
import os


from tensorpack import *
from tensorpack.tfutils.symbolic_functions import *
from tensorpack.tfutils.summary import *

“““
CIFAR10 DenseNet example. See: http://arxiv.org/abs/1608.06993
Code is developed based on Yuxin Wu‘s ResNet implementation: https://github.com/ppwwyyxx/tensorpack/tree/master/examples/ResNet
Results using DenseNet (L=40 K=12) on Cifar10 with data augmentation: ~5.77% test error.

Running time:
On one TITAN X GPU (CUDA 7.5 and cudnn 5.1) the code should run ~5iters/s on a batch size 64.
“““

BATCH_SIZE = 64

class Model(ModelDesc):
    def __init__(self depth):
        super(Model self).__init__()
        self.N = int((depth - 4)  / 3)
        self.growthRate =12

    def _get_inputs(self):
        return [InputDesc(tf.float32 [None 32 32 3] ‘input‘)
                InputDesc(tf.int32 [None] ‘label‘)
               ]

    def _build_graph(self input_vars):
        image label = input_vars
        image = image / 128.0 - 1

        def conv(name l channel stride):
            return Conv2D(name l channel 3 stride=stride
                          nl=tf.identity use_bias=False
                          W_init=tf.random_normal_initializer(stddev=np.sqrt(2.0/9/channel)))
        def add_layer(name l):
            shape = l.get_shape().as_list()
            in_channel = shape[3]
            with tf.variable_scope(name) as scope:
                c = BatchNorm(‘bn1‘ l)
                c = tf.nn.relu(c)
                c = conv(‘conv1‘ c self.growthRate 1)
                l = tf.concat([c l] 3)
            return l

        def add_transition(name l):
            shape = l.get_shape().as_list()
            in_channel = shape[3]
            with tf.variable_scope(name) as scope:
                l = BatchNorm(‘bn1‘ l)
                l = tf.nn.relu(l)
                l = Conv2D(‘conv1‘ l in_channel 1 stride=1 use_bias=False nl=tf.nn.relu)
                l = AvgPooling(‘pool‘ l 2)
            return l


        def dense_net(name):
            l = conv(‘conv0‘ image 16 1)
            with tf.variable_scope(‘block1‘) as scope:

                for i in range(self.N):
                    l = add_layer(‘dense_layer.{}‘.format(i) l)
                l = add_transition(‘transition1‘ l)

            with tf.variable_scope(‘block2‘) as scope:

                for i in range(self.N):
                    l = add_layer(‘dense_layer.{}‘.format(i) l)
                l = add_transition(‘transition2‘ l)

            with tf.variable_scope(‘block3‘) as scope:

                for i in range(self.N):
                    l = add_layer(‘dense_layer.{}‘.format(i) l)
            l = BatchNorm(‘bnlast‘ l)
            l = tf.nn.relu(l)
            l = GlobalAvgPooling(‘gap‘ l)
            logits = FullyConnected(‘linear‘ l out_dim=10 nl=tf.identity)

            return logits

        logits

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        455  2018-05-04 20:50  Architecture.ideaArchitecture.iml

     文件        153  2018-05-04 20:54  Architecture.ideacodestylescodestyleConfig.xml

     文件        198  2018-05-04 20:54  Architecture.ideacodestylesProject.xml

     文件         84  2018-05-04 20:54  Architecture.ideadictionariesYel.xml

     文件        185  2018-05-04 20:54  Architecture.ideamisc.xml

     文件        276  2018-05-04 20:50  Architecture.ideamodules.xml

     文件      40884  2018-05-18 10:35  Architecture.ideaworkspace.xml

     文件      14877  2018-05-17 16:07  Architectureinception_v3.py

     文件       3798  2018-05-15 16:08  Architecture raining.py

     目录          0  2018-05-04 20:54  Architecture.ideacodestyles

     目录          0  2018-05-04 20:54  Architecture.ideadictionaries

     目录          0  2018-05-18 10:35  Architecture.idea

     目录          0  2018-05-18 10:32  Architecture

     文件         97  2018-05-15 17:40  Architecturecheckpoint

     文件       6419  2018-05-17 10:33  Architecturecifar10-densenet.py

     文件       9206  2018-05-14 10:29  Architecturedata_utils.py

     文件       9768  2018-05-18 10:32  ArchitectureDenseNet.py

     文件       5588  2017-05-03 14:44  Architecturehelper.py

     文件   13963728  2018-05-15 17:40  Architectureimage_classification.data-00000-of-00001

     文件      11949  2018-05-15 17:40  Architectureimage_classification.index

     文件    8393363  2018-05-15 17:40  Architectureimage_classification.meta

     文件      11534  2018-05-15 19:21  ArchitectureResNet.py

     文件       7910  2018-05-15 16:17  Architecture\__pycache__data_utils.cpython-36.pyc

     目录          0  2018-05-15 16:17  Architecture\__pycache__

----------- ---------  ---------- -----  ----

             22480472                    24


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)