All Projects → taki0112 → Densenet Tensorflow

taki0112 / Densenet Tensorflow

Licence: mit
Simple Tensorflow implementation of Densenet using Cifar10, MNIST

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Densenet Tensorflow

DenseNet-human-pose-estimation
Using DenseNet for human pose estimation based on TensorFlow.
Stars: ✭ 34 (-93.06%)
Mutual labels:  densenet
DenseNet-MURA-PyTorch
Implementation of DenseNet model on Standford's MURA dataset using PyTorch
Stars: ✭ 59 (-87.96%)
Mutual labels:  densenet
Densenet Caffe
DenseNet Caffe Models, converted from https://github.com/liuzhuang13/DenseNet
Stars: ✭ 350 (-28.57%)
Mutual labels:  densenet
DenseNet-Cifar10
Train DenseNet on Cifar-10 based on Keras
Stars: ✭ 39 (-92.04%)
Mutual labels:  densenet
pyro-vision
Computer vision library for wildfire detection
Stars: ✭ 33 (-93.27%)
Mutual labels:  densenet
Awesome Computer Vision Models
A list of popular deep learning models related to classification, segmentation and detection problems
Stars: ✭ 278 (-43.27%)
Mutual labels:  densenet
densenet
A PyTorch Implementation of "Densely Connected Convolutional Networks"
Stars: ✭ 50 (-89.8%)
Mutual labels:  densenet
Ocr densenet
第一届西安交通大学人工智能实践大赛(2018AI实践大赛--图片文字识别)第一名;仅采用densenet识别图中文字
Stars: ✭ 425 (-13.27%)
Mutual labels:  densenet
3ddensenet.torch
3D DenseNet(torch version) for ModelNet40 dataset
Stars: ✭ 43 (-91.22%)
Mutual labels:  densenet
Tianchi Medical Lungtumordetect
天池医疗AI大赛[第一季]:肺部结节智能诊断 UNet/VGG/Inception/ResNet/DenseNet
Stars: ✭ 314 (-35.92%)
Mutual labels:  densenet
cifar-tensorflow
No description or website provided.
Stars: ✭ 18 (-96.33%)
Mutual labels:  densenet
pytorch2keras
PyTorch to Keras model convertor
Stars: ✭ 788 (+60.82%)
Mutual labels:  densenet
Segmentation models
Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
Stars: ✭ 3,575 (+629.59%)
Mutual labels:  densenet
CNN-Series-Getting-Started-and-PyTorch-Implementation
我的笔记和Demo,包含分类,检测、分割、知识蒸馏。
Stars: ✭ 49 (-90%)
Mutual labels:  densenet
Basic cnns tensorflow2
A tensorflow2 implementation of some basic CNNs(MobileNetV1/V2/V3, EfficientNet, ResNeXt, InceptionV4, InceptionResNetV1/V2, SENet, SqueezeNet, DenseNet, ShuffleNetV2, ResNet).
Stars: ✭ 374 (-23.67%)
Mutual labels:  densenet
pytorch-SRDenseNet
Pytorch implementation for SRDenseNet (ICCV2017)
Stars: ✭ 70 (-85.71%)
Mutual labels:  densenet
Vision networks
Repo about neural networks for images handling
Stars: ✭ 266 (-45.71%)
Mutual labels:  densenet
Awesome Very Deep Learning
♾A curated list of papers and code about very deep neural networks
Stars: ✭ 435 (-11.22%)
Mutual labels:  densenet
Pytorch classification
利用pytorch实现图像分类的一个完整的代码,训练,预测,TTA,模型融合,模型部署,cnn提取特征,svm或者随机森林等进行分类,模型蒸馏,一个完整的代码
Stars: ✭ 395 (-19.39%)
Mutual labels:  densenet
Pytorch Hardnet
35% faster than ResNet: Harmonic DenseNet, A low memory traffic network
Stars: ✭ 293 (-40.2%)
Mutual labels:  densenet

Densenet-Tensorflow

Tensorflow implementation of Densenet using Cifar10, MNIST

  • The code that implements this paper is Densenet.py
  • There is a slight difference, I used AdamOptimizer

If you want to see the original author's code or other implementations, please refer to this link

Requirements

  • Tensorflow 1.x
  • Python 3.x
  • tflearn (If you are easy to use global average pooling, you should install tflearn
However, I implemented it using tf.layers, so don't worry

Issue

  • I used tf.contrib.layers.batch_norm
    def Batch_Normalization(x, training, scope):
        with arg_scope([batch_norm],
                       scope=scope,
                       updates_collections=None,
                       decay=0.9,
                       center=True,
                       scale=True,
                       zero_debias_moving_mean=True) :
            return tf.cond(training,
                           lambda : batch_norm(inputs=x, is_training=training, reuse=None),
                           lambda : batch_norm(inputs=x, is_training=training, reuse=True))
  • If not enough GPU memory, Please edit the code
with tf.Session() as sess : NO
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess : OK

Idea

What is the "Global Average Pooling" ?

    def Global_Average_Pooling(x, stride=1) :
        width = np.shape(x)[1]
        height = np.shape(x)[2]
        pool_size = [width, height]
        return tf.layers.average_pooling2d(inputs=x, pool_size=pool_size, strides=stride) 
        # The stride value does not matter
  • If you use tflearn, please refer to this link
    def Global_Average_Pooling(x):
        return tflearn.layers.conv.global_avg_pool(x, name='Global_avg_pooling')

What is the "Dense Connectivity" ?

Dense_connectivity

What is the "Densenet Architecture" ?

Dense_Architecture

    def Dense_net(self, input_x):
        x = conv_layer(input_x, filter=2 * self.filters, kernel=[7,7], stride=2, layer_name='conv0')
        x = Max_Pooling(x, pool_size=[3,3], stride=2)

        x = self.dense_block(input_x=x, nb_layers=6, layer_name='dense_1')
        x = self.transition_layer(x, scope='trans_1')

        x = self.dense_block(input_x=x, nb_layers=12, layer_name='dense_2')
        x = self.transition_layer(x, scope='trans_2')

        x = self.dense_block(input_x=x, nb_layers=48, layer_name='dense_3')
        x = self.transition_layer(x, scope='trans_3')

        x = self.dense_block(input_x=x, nb_layers=32, layer_name='dense_final') 
        
        x = Batch_Normalization(x, training=self.training, scope='linear_batch')
        x = Relu(x)
        x = Global_Average_Pooling(x)
        x = Linear(x)

        return x

What is the "Dense Block" ?

Dense_block

    def dense_block(self, input_x, nb_layers, layer_name):
        with tf.name_scope(layer_name):
            layers_concat = list()
            layers_concat.append(input_x)

            x = self.bottleneck_layer(input_x, scope=layer_name + '_bottleN_' + str(0))

            layers_concat.append(x)

            for i in range(nb_layers - 1):
                x = Concatenation(layers_concat)
                x = self.bottleneck_layer(x, scope=layer_name + '_bottleN_' + str(i + 1))
                layers_concat.append(x)

            x = Concatenation(layers_concat)
            
            return x

What is the "Bottleneck Layer" ?

    def bottleneck_layer(self, x, scope):
        with tf.name_scope(scope):
            x = Batch_Normalization(x, training=self.training, scope=scope+'_batch1')
            x = Relu(x)
            x = conv_layer(x, filter=4 * self.filters, kernel=[1,1], layer_name=scope+'_conv1')
            x = Drop_out(x, rate=dropout_rate, training=self.training)

            x = Batch_Normalization(x, training=self.training, scope=scope+'_batch2')
            x = Relu(x)
            x = conv_layer(x, filter=self.filters, kernel=[3,3], layer_name=scope+'_conv2')
            x = Drop_out(x, rate=dropout_rate, training=self.training)
            
            return x

What is the "Transition Layer" ?

    def transition_layer(self, x, scope):
        with tf.name_scope(scope):
            x = Batch_Normalization(x, training=self.training, scope=scope+'_batch1')
            x = Relu(x)
            x = conv_layer(x, filter=self.filters, kernel=[1,1], layer_name=scope+'_conv1')
            x = Drop_out(x, rate=dropout_rate, training=self.training)
            x = Average_pooling(x, pool_size=[2,2], stride=2)

            return x

Compare Structure (CNN, ResNet, DenseNet)

compare

Results

  • (MNIST) The highest test accuracy is 99.2% (This result does not use dropout)
  • The number of dense block layers is fixed to 4
    for i in range(self.nb_blocks) :
        # original : 6 -> 12 -> 48

        x = self.dense_block(input_x=x, nb_layers=4, layer_name='dense_'+str(i))
        x = self.transition_layer(x, scope='trans_'+str(i))

CIFAR-10

cifar_10

CIFAR-100

cifar_100

Image Net

image_net

Related works

References

Author

Junho Kim

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].